Merge pull request #377 from realrunner/bug/postgres-array-detection
Bug/postgres array detection
This commit is contained in:
commit
b835e25665
2 changed files with 15 additions and 5 deletions
|
|
@ -65,11 +65,12 @@ select
|
||||||
not attr.attnotnull as "column.isNullable",
|
not attr.attnotnull as "column.isNullable",
|
||||||
attr.attgenerated = 's' as "column.isGenerated",
|
attr.attgenerated = 's' as "column.isGenerated",
|
||||||
attr.atthasdef as "column.hasDefault",
|
attr.atthasdef as "column.hasDefault",
|
||||||
(case tp.typtype
|
(case
|
||||||
when 'b' then 'base'
|
when tp.typtype = 'b' AND tp.typcategory <> 'A' then 'base'
|
||||||
when 'd' then 'base'
|
when tp.typtype = 'b' AND tp.typcategory = 'A' then 'array'
|
||||||
when 'e' then 'enum'
|
when tp.typtype = 'd' then 'base'
|
||||||
when 'r' then 'range'
|
when tp.typtype = 'e' then 'enum'
|
||||||
|
when tp.typtype = 'r' then 'range'
|
||||||
end) as "dataType.Kind",
|
end) as "dataType.Kind",
|
||||||
(case when tp.typtype = 'd' then (select pg_type.typname from pg_catalog.pg_type where pg_type.oid = tp.typbasetype)
|
(case when tp.typtype = 'd' then (select pg_type.typname from pg_catalog.pg_type where pg_type.oid = tp.typbasetype)
|
||||||
when tp.typcategory = 'A' then pg_catalog.format_type(attr.atttypid, attr.atttypmod)
|
when tp.typcategory = 'A' then pg_catalog.format_type(attr.atttypid, attr.atttypmod)
|
||||||
|
|
|
||||||
|
|
@ -222,10 +222,18 @@ func TestGenerator_TableMetadata(t *testing.T) {
|
||||||
// Spot check the actor table and assert that the emitted
|
// Spot check the actor table and assert that the emitted
|
||||||
// properties are as expected.
|
// properties are as expected.
|
||||||
var got metadata.Table
|
var got metadata.Table
|
||||||
|
var specialFeatures metadata.Column
|
||||||
for _, table := range schema.TablesMetaData {
|
for _, table := range schema.TablesMetaData {
|
||||||
if table.Name == "actor" {
|
if table.Name == "actor" {
|
||||||
got = table
|
got = table
|
||||||
}
|
}
|
||||||
|
if table.Name == "film" {
|
||||||
|
for _, column := range table.Columns {
|
||||||
|
if column.Name == "special_features" {
|
||||||
|
specialFeatures = column
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
want := metadata.Table{
|
want := metadata.Table{
|
||||||
|
|
@ -238,6 +246,7 @@ func TestGenerator_TableMetadata(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
require.Equal(t, want, got)
|
require.Equal(t, want, got)
|
||||||
|
require.Equal(t, metadata.ArrayType, specialFeatures.DataType.Kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGeneratorSpecialCharacters(t *testing.T) {
|
func TestGeneratorSpecialCharacters(t *testing.T) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue