Skip to content

Commit

Permalink
pg-gen: implement information_schema shema (#1815)
Browse files Browse the repository at this point in the history
  • Loading branch information
skabbes authored Aug 23, 2022
1 parent 8fa5272 commit eea73f6
Show file tree
Hide file tree
Showing 29 changed files with 34,403 additions and 211 deletions.
2 changes: 1 addition & 1 deletion internal/codegen/golang/postgresql_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func postgresType(req *plugin.CodeGenRequest, col *plugin.Column) string {
}

for _, schema := range req.Catalog.Schemas {
if schema.Name == "pg_catalog" {
if schema.Name == "pg_catalog" || schema.Name == "information_schema" {
continue
}

Expand Down
9 changes: 5 additions & 4 deletions internal/codegen/golang/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func buildEnums(req *plugin.CodeGenRequest) []Enum {
var enums []Enum
for _, schema := range req.Catalog.Schemas {
if schema.Name == "pg_catalog" {
if schema.Name == "pg_catalog" || schema.Name == "information_schema" {
continue
}
for _, enum := range schema.Enums {
Expand Down Expand Up @@ -52,7 +52,7 @@ func buildEnums(req *plugin.CodeGenRequest) []Enum {
func buildStructs(req *plugin.CodeGenRequest) []Struct {
var structs []Struct
for _, schema := range req.Catalog.Schemas {
if schema.Name == "pg_catalog" {
if schema.Name == "pg_catalog" || schema.Name == "information_schema" {
continue
}
for _, table := range schema.Tables {
Expand Down Expand Up @@ -253,8 +253,9 @@ func buildQueries(req *plugin.CodeGenRequest, structs []Struct) ([]Query, error)

// It's possible that this method will generate duplicate JSON tag values
//
// Columns: count, count, count_2
// Fields: Count, Count_2, Count2
// Columns: count, count, count_2
// Fields: Count, Count_2, Count2
//
// JSON tags: count, count_2, count_2
//
// This is unlikely to happen, so don't fix it yet
Expand Down
4 changes: 2 additions & 2 deletions internal/codegen/kotlin/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func ktEnumValueName(value string) string {
func buildEnums(req *plugin.CodeGenRequest) []Enum {
var enums []Enum
for _, schema := range req.Catalog.Schemas {
if schema.Name == "pg_catalog" {
if schema.Name == "pg_catalog" || schema.Name == "information_schema" {
continue
}
for _, enum := range schema.Enums {
Expand Down Expand Up @@ -265,7 +265,7 @@ func memberName(name string, settings *plugin.Settings) string {
func buildDataClasses(req *plugin.CodeGenRequest) []Struct {
var structs []Struct
for _, schema := range req.Catalog.Schemas {
if schema.Name == "pg_catalog" {
if schema.Name == "pg_catalog" || schema.Name == "information_schema" {
continue
}
for _, table := range schema.Tables {
Expand Down
2 changes: 1 addition & 1 deletion internal/codegen/kotlin/postgresql_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func postgresType(req *plugin.CodeGenRequest, col *plugin.Column) (string, bool)

default:
for _, schema := range req.Catalog.Schemas {
if schema.Name == "pg_catalog" {
if schema.Name == "pg_catalog" || schema.Name == "information_schema" {
continue
}
for _, enum := range schema.Enums {
Expand Down
4 changes: 2 additions & 2 deletions internal/codegen/python/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func pyEnumValueName(value string) string {
func buildEnums(req *plugin.CodeGenRequest) []Enum {
var enums []Enum
for _, schema := range req.Catalog.Schemas {
if schema.Name == "pg_catalog" {
if schema.Name == "pg_catalog" || schema.Name == "information_schema" {
continue
}
for _, enum := range schema.Enums {
Expand Down Expand Up @@ -277,7 +277,7 @@ func buildEnums(req *plugin.CodeGenRequest) []Enum {
func buildModels(req *plugin.CodeGenRequest) []Struct {
var structs []Struct
for _, schema := range req.Catalog.Schemas {
if schema.Name == "pg_catalog" {
if schema.Name == "pg_catalog" || schema.Name == "information_schema" {
continue
}
for _, table := range schema.Tables {
Expand Down
2 changes: 1 addition & 1 deletion internal/codegen/python/postgresql_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func postgresType(req *plugin.CodeGenRequest, col *plugin.Column) string {
return "str"
default:
for _, schema := range req.Catalog.Schemas {
if schema.Name == "pg_catalog" {
if schema.Name == "pg_catalog" || schema.Name == "information_schema" {
continue
}
for _, enum := range schema.Enums {
Expand Down
Loading

0 comments on commit eea73f6

Please sign in to comment.