diff --git a/CHANGELOG.md b/CHANGELOG.md index e7b928f8..aa3e96ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added error constants for matching against both specific and generic unique constraint errors raised by the underlying database driver. (thanks @mbezhanov) +- Added support for regular expressions in the `only` and `except` table filters. (thanks @mbezhanov) ### Removed @@ -52,8 +53,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Removed unnecessary import of `strings` in `bobfactory_random.go`. -- Fixed data races in unit tests. +- Fixed data races in unit tests. (thanks @mbezhanov) - Fixed invalid SQL statements generated by `sm.OrderBy().Collate()`. (thanks @mbezhanov) +- Fixed a bug preventing specific columns from being excluded when generating models from SQLite. (thanks @mbezhanov) ## [v0.28.1] - 2024-06-28 diff --git a/gen/bobgen-mysql/driver/exclude-tables.golden.json b/gen/bobgen-mysql/driver/exclude-tables.golden.json new file mode 100644 index 00000000..253425b2 --- /dev/null +++ b/gen/bobgen-mysql/driver/exclude-tables.golden.json @@ -0,0 +1,2117 @@ +{ + "tables": [ + { + "key": "bar_baz", + "schema": "", + "name": "bar_baz", + "columns": [ + { + "name": "id", + "db_type": "int", + "default": "AUTO_INCREMENT", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": true, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "PRIMARY", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "bar_qux", + "schema": "", + "name": "bar_qux", + "columns": [ + { + "name": "id", + "db_type": "int", + "default": "AUTO_INCREMENT", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": true, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "PRIMARY", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "foo_qux", + "schema": "", + "name": "foo_qux", + "columns": [ + { + "name": "id", + "db_type": "int", + "default": "AUTO_INCREMENT", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": true, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "PRIMARY", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "multi_keys", + "schema": "", + "name": "multi_keys", + "columns": [ + { + "name": "id", + "db_type": "int", + "default": "AUTO_INCREMENT", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": true, + "domain_name": "", + "type": "int32" + }, + { + "name": "user_id", + "db_type": "int", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "sponsor_id", + "db_type": "int", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "something", + "db_type": "int", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "another", + "db_type": "int", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "one", + "db_type": "int", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "two", + "db_type": "int", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "one", + "columns": [ + "one", + "two" + ], + "expressions": null + }, + { + "name": "PRIMARY", + "columns": [ + "id" + ], + "expressions": null + }, + { + "name": "something", + "columns": [ + "something", + "another" + ], + "expressions": null + }, + { + "name": "sponsor_id", + "columns": [ + "sponsor_id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "id" + ] + }, + "foreign": [ + { + "name": "multi_keys_ibfk_1", + "columns": [ + "one", + "two" + ], + "foreign_table": "type_monsters", + "foreign_columns": [ + "int_one", + "int_two" + ] + } + ], + "uniques": [ + { + "name": "something", + "columns": [ + "something", + "another" + ] + }, + { + "name": "sponsor_id", + "columns": [ + "sponsor_id" + ] + } + ] + } + }, + { + "key": "sponsors", + "schema": "", + "name": "sponsors", + "columns": [ + { + "name": "id", + "db_type": "int", + "default": "AUTO_INCREMENT", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": true, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "PRIMARY", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "tags", + "schema": "", + "name": "tags", + "columns": [ + { + "name": "id", + "db_type": "int", + "default": "AUTO_INCREMENT", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": true, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "PRIMARY", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "test_index_expressions", + "schema": "", + "name": "test_index_expressions", + "columns": [ + { + "name": "col1", + "db_type": "int", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "col2", + "db_type": "int", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "col3", + "db_type": "int", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "idx1", + "columns": null, + "expressions": [ + "(`col1` + `col2`)" + ] + }, + { + "name": "idx2", + "columns": [ + "col3" + ], + "expressions": [ + "(`col1` + `col2`)" + ] + }, + { + "name": "idx3", + "columns": [ + "col1" + ], + "expressions": [ + "(`col2` + `col3`)" + ] + }, + { + "name": "idx4", + "columns": [ + "col3" + ], + "expressions": null + }, + { + "name": "idx5", + "columns": [ + "col1", + "col2" + ], + "expressions": null + }, + { + "name": "idx6", + "columns": null, + "expressions": [ + "pow(`col3`,2)" + ] + } + ], + "constraints": { + "primary": null, + "foreign": null, + "uniques": null + } + }, + { + "key": "type_monsters", + "schema": "", + "name": "type_monsters", + "columns": [ + { + "name": "id", + "db_type": "int", + "default": "AUTO_INCREMENT", + "comment": "comment on ID", + "nullable": false, + "generated": false, + "autoincr": true, + "domain_name": "", + "type": "int32" + }, + { + "name": "enum_use", + "db_type": "enum", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "TypeMonstersEnumUse" + }, + { + "name": "enum_nullable", + "db_type": "enum", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "TypeMonstersEnumNullable" + }, + { + "name": "id_two", + "db_type": "int", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "id_three", + "db_type": "int", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "bool_zero", + "db_type": "bool", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "bool_one", + "db_type": "bool", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "bool_two", + "db_type": "bool", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "bool_three", + "db_type": "bool", + "default": "0", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "bool_four", + "db_type": "bool", + "default": "1", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "bool_five", + "db_type": "bool", + "default": "0", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "bool_six", + "db_type": "bool", + "default": "1", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "string_zero", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_one", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_two", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_three", + "db_type": "varchar", + "default": "a", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_four", + "db_type": "varchar", + "default": "b", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_five", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_six", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_seven", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_eight", + "db_type": "varchar", + "default": "abcdefgh", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_nine", + "db_type": "varchar", + "default": "abcdefgh", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_ten", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_eleven", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "big_int_zero", + "db_type": "bigint", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_one", + "db_type": "bigint", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_two", + "db_type": "bigint", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_three", + "db_type": "bigint", + "default": "111111", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_four", + "db_type": "bigint", + "default": "222222", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_five", + "db_type": "bigint", + "default": "0", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_six", + "db_type": "bigint", + "default": "0", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_seven", + "db_type": "bigint", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "uint64" + }, + { + "name": "big_int_eight", + "db_type": "bigint", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "uint64" + }, + { + "name": "int_zero", + "db_type": "int", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_one", + "db_type": "int", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_two", + "db_type": "int", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_three", + "db_type": "int", + "default": "333333", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_four", + "db_type": "int", + "default": "444444", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_five", + "db_type": "int", + "default": "0", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_six", + "db_type": "int", + "default": "0", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_seven", + "db_type": "int", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "uint32" + }, + { + "name": "int_eight", + "db_type": "int", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "uint32" + }, + { + "name": "float_zero", + "db_type": "float", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float32" + }, + { + "name": "float_one", + "db_type": "float", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float32" + }, + { + "name": "float_two", + "db_type": "float", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float32" + }, + { + "name": "float_three", + "db_type": "float", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float32" + }, + { + "name": "float_four", + "db_type": "float", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float32" + }, + { + "name": "float_five", + "db_type": "float", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float32" + }, + { + "name": "float_six", + "db_type": "float", + "default": "1.1", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float32" + }, + { + "name": "float_seven", + "db_type": "float", + "default": "1.1", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float32" + }, + { + "name": "float_eight", + "db_type": "float", + "default": "0.0", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float32" + }, + { + "name": "float_nine", + "db_type": "float", + "default": "0.0", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float32" + }, + { + "name": "bytea_zero", + "db_type": "binary", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_one", + "db_type": "binary", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_two", + "db_type": "binary", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_three", + "db_type": "binary", + "default": "0x61", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_four", + "db_type": "binary", + "default": "0x62", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_five", + "db_type": "binary", + "default": "0x616263646566676861626364656667686162636465666768", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_six", + "db_type": "binary", + "default": "0x686766656463626168676665646362616867666564636261", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_seven", + "db_type": "binary", + "default": "0x", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_eight", + "db_type": "binary", + "default": "0x", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "time_zero", + "db_type": "timestamp", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_one", + "db_type": "date", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_two", + "db_type": "timestamp", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_three", + "db_type": "timestamp", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_five", + "db_type": "timestamp", + "default": "CURRENT_TIMESTAMP", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_nine", + "db_type": "timestamp", + "default": "CURRENT_TIMESTAMP", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_eleven", + "db_type": "date", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_twelve", + "db_type": "date", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_fifteen", + "db_type": "date", + "default": "1999-01-08", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_sixteen", + "db_type": "date", + "default": "1999-01-08", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "json_null", + "db_type": "json", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "types.JSON[json.RawMessage]" + }, + { + "name": "json_nnull", + "db_type": "json", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "types.JSON[json.RawMessage]" + }, + { + "name": "tinyint_null", + "db_type": "tinyint", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int8" + }, + { + "name": "tinyint_nnull", + "db_type": "tinyint", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int8" + }, + { + "name": "tinyint1_null", + "db_type": "bool", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "tinyint1_nnull", + "db_type": "bool", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "tinyint2_null", + "db_type": "tinyint", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int8" + }, + { + "name": "tinyint2_nnull", + "db_type": "tinyint", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int8" + }, + { + "name": "smallint_null", + "db_type": "smallint", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int16" + }, + { + "name": "smallint_nnull", + "db_type": "smallint", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int16" + }, + { + "name": "mediumint_null", + "db_type": "mediumint", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "mediumint_nnull", + "db_type": "mediumint", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "bigint_null", + "db_type": "bigint", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "bigint_nnull", + "db_type": "bigint", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "float_null", + "db_type": "float", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float32" + }, + { + "name": "float_nnull", + "db_type": "float", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float32" + }, + { + "name": "double_null", + "db_type": "double", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float64" + }, + { + "name": "double_nnull", + "db_type": "double", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float64" + }, + { + "name": "doubleprec_null", + "db_type": "double", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float64" + }, + { + "name": "doubleprec_nnull", + "db_type": "double", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float64" + }, + { + "name": "real_null", + "db_type": "double", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float64" + }, + { + "name": "real_nnull", + "db_type": "double", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float64" + }, + { + "name": "boolean_null", + "db_type": "bool", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "boolean_nnull", + "db_type": "bool", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "date_null", + "db_type": "date", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "date_nnull", + "db_type": "date", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "datetime_null", + "db_type": "datetime", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "datetime_nnull", + "db_type": "datetime", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "timestamp_null", + "db_type": "timestamp", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "timestamp_nnull", + "db_type": "timestamp", + "default": "CURRENT_TIMESTAMP", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "binary_null", + "db_type": "binary", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "binary_nnull", + "db_type": "binary", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "varbinary_null", + "db_type": "varbinary", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "varbinary_nnull", + "db_type": "varbinary", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "tinyblob_null", + "db_type": "tinyblob", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "tinyblob_nnull", + "db_type": "tinyblob", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "blob_null", + "db_type": "blob", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "blob_nnull", + "db_type": "blob", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "mediumblob_null", + "db_type": "mediumblob", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "mediumblob_nnull", + "db_type": "mediumblob", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "longblob_null", + "db_type": "longblob", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "longblob_nnull", + "db_type": "longblob", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "varchar_null", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "varchar_nnull", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "char_null", + "db_type": "char", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "char_nnull", + "db_type": "char", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "text_null", + "db_type": "text", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "text_nnull", + "db_type": "text", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "virtual_nnull", + "db_type": "text", + "default": "AUTO_GENERATED", + "comment": "", + "nullable": false, + "generated": true, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "virtual_null", + "db_type": "text", + "default": "AUTO_GENERATED", + "comment": "", + "nullable": true, + "generated": true, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "generated_nnull", + "db_type": "text", + "default": "AUTO_GENERATED", + "comment": "", + "nullable": false, + "generated": true, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "generated_null", + "db_type": "text", + "default": "AUTO_GENERATED", + "comment": "", + "nullable": true, + "generated": true, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "int_one", + "columns": [ + "int_one", + "int_two" + ], + "expressions": null + }, + { + "name": "PRIMARY", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": [ + { + "name": "int_one", + "columns": [ + "int_one", + "int_two" + ] + } + ] + } + }, + { + "key": "user_videos", + "schema": "", + "name": "user_videos", + "columns": [ + { + "name": "user_id", + "db_type": "int", + "default": "0", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "video_id", + "db_type": "int", + "default": "0", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "sponsor_id", + "db_type": "int", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": null, + "constraints": { + "primary": null, + "foreign": null, + "uniques": null + } + }, + { + "key": "users", + "schema": "", + "name": "users", + "columns": [ + { + "name": "id", + "db_type": "int", + "default": "AUTO_INCREMENT", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": true, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "PRIMARY", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "video_tags", + "schema": "", + "name": "video_tags", + "columns": [ + { + "name": "video_id", + "db_type": "int", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "tag_id", + "db_type": "int", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "PRIMARY", + "columns": [ + "video_id", + "tag_id" + ], + "expressions": null + }, + { + "name": "tag_id", + "columns": [ + "tag_id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "video_id", + "tag_id" + ] + }, + "foreign": [ + { + "name": "video_tags_ibfk_1", + "columns": [ + "video_id" + ], + "foreign_table": "videos", + "foreign_columns": [ + "id" + ] + }, + { + "name": "video_tags_ibfk_2", + "columns": [ + "tag_id" + ], + "foreign_table": "tags", + "foreign_columns": [ + "id" + ] + } + ], + "uniques": null + } + }, + { + "key": "videos", + "schema": "", + "name": "videos", + "columns": [ + { + "name": "id", + "db_type": "int", + "default": "AUTO_INCREMENT", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": true, + "domain_name": "", + "type": "int32" + }, + { + "name": "user_id", + "db_type": "int", + "default": "", + "comment": "this is a comment", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "sponsor_id", + "db_type": "int", + "default": "", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "PRIMARY", + "columns": [ + "id" + ], + "expressions": null + }, + { + "name": "sponsor_id", + "columns": [ + "sponsor_id" + ], + "expressions": null + }, + { + "name": "user_id", + "columns": [ + "user_id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "id" + ] + }, + "foreign": [ + { + "name": "videos_ibfk_1", + "columns": [ + "user_id" + ], + "foreign_table": "users", + "foreign_columns": [ + "id" + ] + }, + { + "name": "videos_ibfk_2", + "columns": [ + "sponsor_id" + ], + "foreign_table": "sponsors", + "foreign_columns": [ + "id" + ] + } + ], + "uniques": [ + { + "name": "sponsor_id", + "columns": [ + "sponsor_id" + ] + } + ] + } + } + ], + "enums": [ + { + "Type": "TypeMonstersEnumNullable", + "Values": [ + "monday", + "tuesday", + "wednesday", + "thursday", + "friday" + ] + }, + { + "Type": "TypeMonstersEnumUse", + "Values": [ + "monday", + "tuesday", + "wednesday", + "thursday", + "friday" + ] + } + ], + "extra_info": null, + "driver_name": "github.com/go-sql-driver/mysql" +} \ No newline at end of file diff --git a/gen/bobgen-mysql/driver/include-exclude-tables-mixed.golden.json b/gen/bobgen-mysql/driver/include-exclude-tables-mixed.golden.json new file mode 100644 index 00000000..8b2f8e31 --- /dev/null +++ b/gen/bobgen-mysql/driver/include-exclude-tables-mixed.golden.json @@ -0,0 +1,103 @@ +{ + "tables": [ + { + "key": "bar_baz", + "schema": "", + "name": "bar_baz", + "columns": [ + { + "name": "id", + "db_type": "int", + "default": "AUTO_INCREMENT", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": true, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "PRIMARY", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "bar_qux", + "schema": "", + "name": "bar_qux", + "columns": [ + { + "name": "id", + "db_type": "int", + "default": "AUTO_INCREMENT", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": true, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "PRIMARY", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + } + ], + "enums": null, + "extra_info": null, + "driver_name": "github.com/go-sql-driver/mysql" +} \ No newline at end of file diff --git a/gen/bobgen-mysql/driver/include-exclude-tables-regex.golden.json b/gen/bobgen-mysql/driver/include-exclude-tables-regex.golden.json new file mode 100644 index 00000000..f99c25d7 --- /dev/null +++ b/gen/bobgen-mysql/driver/include-exclude-tables-regex.golden.json @@ -0,0 +1,103 @@ +{ + "tables": [ + { + "key": "bar_qux", + "schema": "", + "name": "bar_qux", + "columns": [ + { + "name": "id", + "db_type": "int", + "default": "AUTO_INCREMENT", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": true, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "PRIMARY", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "foo_qux", + "schema": "", + "name": "foo_qux", + "columns": [ + { + "name": "id", + "db_type": "int", + "default": "AUTO_INCREMENT", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": true, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "PRIMARY", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + } + ], + "enums": null, + "extra_info": null, + "driver_name": "github.com/go-sql-driver/mysql" +} \ No newline at end of file diff --git a/gen/bobgen-mysql/driver/include-exclude-tables.golden.json b/gen/bobgen-mysql/driver/include-exclude-tables.golden.json new file mode 100644 index 00000000..f73cc301 --- /dev/null +++ b/gen/bobgen-mysql/driver/include-exclude-tables.golden.json @@ -0,0 +1,55 @@ +{ + "tables": [ + { + "key": "foo_baz", + "schema": "", + "name": "foo_baz", + "columns": [ + { + "name": "id", + "db_type": "int", + "default": "AUTO_INCREMENT", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": true, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "PRIMARY", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + } + ], + "enums": null, + "extra_info": null, + "driver_name": "github.com/go-sql-driver/mysql" +} \ No newline at end of file diff --git a/gen/bobgen-mysql/driver/include-tables.golden.json b/gen/bobgen-mysql/driver/include-tables.golden.json new file mode 100644 index 00000000..2b12154d --- /dev/null +++ b/gen/bobgen-mysql/driver/include-tables.golden.json @@ -0,0 +1,103 @@ +{ + "tables": [ + { + "key": "foo_bar", + "schema": "", + "name": "foo_bar", + "columns": [ + { + "name": "id", + "db_type": "int", + "default": "AUTO_INCREMENT", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": true, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "PRIMARY", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "foo_baz", + "schema": "", + "name": "foo_baz", + "columns": [ + { + "name": "id", + "db_type": "int", + "default": "AUTO_INCREMENT", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": true, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "PRIMARY", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + } + ], + "enums": null, + "extra_info": null, + "driver_name": "github.com/go-sql-driver/mysql" +} \ No newline at end of file diff --git a/gen/bobgen-mysql/driver/mysql.go b/gen/bobgen-mysql/driver/mysql.go index 62eef2ed..05ec4685 100644 --- a/gen/bobgen-mysql/driver/mysql.go +++ b/gen/bobgen-mysql/driver/mysql.go @@ -124,17 +124,35 @@ func (d *driver) TablesInfo(ctx context.Context, tableFilter drivers.Filter) (dr exclude := tableFilter.Except if len(include) > 0 { - query += fmt.Sprintf(" and table_name in (%s)", strmangle.Placeholders(false, len(include), 1, 1)) // third param is not used for ? placeholders - for _, w := range include { - args = append(args, w) + var subqueries []string + stringPatterns, regexPatterns := tableFilter.ClassifyPatterns(include) + if len(stringPatterns) > 0 { + subqueries = append(subqueries, fmt.Sprintf("table_name in (%s)", strmangle.Placeholders(false, len(stringPatterns), 1, 1))) // third param is not used for ? placeholders + for _, w := range stringPatterns { + args = append(args, w) + } + } + if len(regexPatterns) > 0 { + subqueries = append(subqueries, "table_name regexp (?)") + args = append(args, strings.Join(regexPatterns, "|")) } + query += fmt.Sprintf(" and (%s)", strings.Join(subqueries, " or ")) } if len(exclude) > 0 { - query += fmt.Sprintf(" and table_name not in (%s)", strmangle.Placeholders(false, len(exclude), 1, 1)) // third param is not used for ? placeholders - for _, w := range exclude { - args = append(args, w) + var subqueries []string + stringPatterns, regexPatterns := tableFilter.ClassifyPatterns(exclude) + if len(stringPatterns) > 0 { + subqueries = append(subqueries, fmt.Sprintf("table_name not in (%s)", strmangle.Placeholders(false, len(stringPatterns), 1, 1))) // third param is not used for ? placeholders + for _, w := range stringPatterns { + args = append(args, w) + } + } + if len(regexPatterns) > 0 { + subqueries = append(subqueries, "table_name not regexp (?)") + args = append(args, strings.Join(regexPatterns, "|")) } + query += fmt.Sprintf(" and (%s)", strings.Join(subqueries, " and ")) } query += ` order by table_name;` diff --git a/gen/bobgen-mysql/driver/mysql.golden.json b/gen/bobgen-mysql/driver/mysql.golden.json index 64f346cc..8db2187a 100644 --- a/gen/bobgen-mysql/driver/mysql.golden.json +++ b/gen/bobgen-mysql/driver/mysql.golden.json @@ -1,5 +1,245 @@ { "tables": [ + { + "key": "bar_baz", + "schema": "", + "name": "bar_baz", + "columns": [ + { + "name": "id", + "db_type": "int", + "default": "AUTO_INCREMENT", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": true, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "PRIMARY", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "bar_qux", + "schema": "", + "name": "bar_qux", + "columns": [ + { + "name": "id", + "db_type": "int", + "default": "AUTO_INCREMENT", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": true, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "PRIMARY", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "foo_bar", + "schema": "", + "name": "foo_bar", + "columns": [ + { + "name": "id", + "db_type": "int", + "default": "AUTO_INCREMENT", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": true, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "PRIMARY", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "foo_baz", + "schema": "", + "name": "foo_baz", + "columns": [ + { + "name": "id", + "db_type": "int", + "default": "AUTO_INCREMENT", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": true, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "PRIMARY", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "foo_qux", + "schema": "", + "name": "foo_qux", + "columns": [ + { + "name": "id", + "db_type": "int", + "default": "AUTO_INCREMENT", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": true, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "varchar", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "PRIMARY", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "PRIMARY", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, { "key": "multi_keys", "schema": "", @@ -1705,7 +1945,15 @@ ] }, "foreign": null, - "uniques": null + "uniques": [ + { + "name": "int_one", + "columns": [ + "int_one", + "int_two" + ] + } + ] } }, { diff --git a/gen/bobgen-mysql/driver/mysql_test.go b/gen/bobgen-mysql/driver/mysql_test.go index df9513d9..203205b3 100644 --- a/gen/bobgen-mysql/driver/mysql_test.go +++ b/gen/bobgen-mysql/driver/mysql_test.go @@ -87,6 +87,76 @@ func TestDriver(t *testing.T) { }, goldenJson: "mysql.golden.json", }, + { + name: "include tables", + config: Config{ + Dsn: dsn, + Only: map[string][]string{ + "foo_bar": nil, + "foo_baz": nil, + }, + }, + goldenJson: "include-tables.golden.json", + }, + { + name: "exclude tables", + config: Config{ + Dsn: dsn, + Except: map[string][]string{ + "foo_bar": nil, + "foo_baz": nil, + "*": {"secret_col"}, + }, + }, + goldenJson: "exclude-tables.golden.json", + }, + { + name: "include + exclude tables", + config: Config{ + Dsn: dsn, + Only: map[string][]string{ + "foo_bar": nil, + "foo_baz": nil, + }, + Except: map[string][]string{ + "foo_bar": nil, + "bar_baz": nil, + }, + }, + goldenJson: "include-exclude-tables.golden.json", + }, + { + name: "include + exclude tables regex", + config: Config{ + Dsn: dsn, + Only: map[string][]string{ + "/^foo/": nil, + "/^bar/": nil, + }, + Except: map[string][]string{ + "/bar$/": nil, + "/baz$/": nil, + }, + }, + goldenJson: "include-exclude-tables-regex.golden.json", + }, + { + name: "include + exclude tables mixed", + config: Config{ + Dsn: dsn, + Only: map[string][]string{ + "/^foo/": nil, + "bar_baz": nil, + "bar_qux": nil, + }, + Except: map[string][]string{ + "/bar$/": nil, + "foo_baz": nil, + "foo_qux": nil, + }, + }, + goldenJson: "include-exclude-tables-mixed.golden.json", + }, } for _, tt := range tests { diff --git a/gen/bobgen-psql/driver/exclude-tables.golden.json b/gen/bobgen-psql/driver/exclude-tables.golden.json new file mode 100644 index 00000000..090353da --- /dev/null +++ b/gen/bobgen-psql/driver/exclude-tables.golden.json @@ -0,0 +1,4251 @@ +{ + "tables": [ + { + "key": "bar_baz", + "schema": "", + "name": "bar_baz", + "columns": [ + { + "name": "id", + "db_type": "integer", + "default": "nextval('bar_baz_id_seq'::regclass)", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "bar_baz_pkey", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "bar_baz_pkey", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "bar_qux", + "schema": "", + "name": "bar_qux", + "columns": [ + { + "name": "id", + "db_type": "integer", + "default": "nextval('bar_qux_id_seq'::regclass)", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "bar_qux_pkey", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "bar_qux_pkey", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "foo_qux", + "schema": "", + "name": "foo_qux", + "columns": [ + { + "name": "id", + "db_type": "integer", + "default": "nextval('foo_qux_id_seq'::regclass)", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "foo_qux_pkey", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "foo_qux_pkey", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "sponsors", + "schema": "", + "name": "sponsors", + "columns": [ + { + "name": "id", + "db_type": "integer", + "default": "nextval('sponsors_id_seq'::regclass)", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "sponsors_pkey", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "sponsors_pkey", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "tags", + "schema": "", + "name": "tags", + "columns": [ + { + "name": "id", + "db_type": "integer", + "default": "nextval('tags_id_seq'::regclass)", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "tags_pkey", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "tags_pkey", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "test_index_expressions", + "schema": "", + "name": "test_index_expressions", + "columns": [ + { + "name": "col1", + "db_type": "integer", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "col2", + "db_type": "integer", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "col3", + "db_type": "integer", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "idx1", + "columns": null, + "expressions": [ + "(col1 + col2)" + ] + }, + { + "name": "idx2", + "columns": [ + "col3" + ], + "expressions": [ + "(col1 + col2)" + ] + }, + { + "name": "idx3", + "columns": [ + "col1" + ], + "expressions": [ + "(col2 + col3)" + ] + }, + { + "name": "idx4", + "columns": [ + "col3" + ], + "expressions": null + }, + { + "name": "idx5", + "columns": [ + "col1", + "col2" + ], + "expressions": null + }, + { + "name": "idx6", + "columns": null, + "expressions": [ + "pow(col3::double precision, 2::double precision)" + ] + } + ], + "constraints": { + "primary": null, + "foreign": null, + "uniques": null + } + }, + { + "key": "type_monsters", + "schema": "", + "name": "type_monsters", + "columns": [ + { + "name": "id", + "db_type": "integer", + "default": "nextval('type_monsters_id_seq'::regclass)", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "enum_use", + "db_type": "ENUM", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "UnicodeEnum" + }, + { + "name": "enum_nullable", + "db_type": "ENUM", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "UnicodeEnum" + }, + { + "name": "bool_zero", + "db_type": "boolean", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "bool_one", + "db_type": "boolean", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "bool_two", + "db_type": "boolean", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "bool_three", + "db_type": "boolean", + "default": "false", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "bool_four", + "db_type": "boolean", + "default": "true", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "bool_five", + "db_type": "boolean", + "default": "false", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "bool_six", + "db_type": "boolean", + "default": "true", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "string_zero", + "db_type": "character varying", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_one", + "db_type": "character varying", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_two", + "db_type": "character varying", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_three", + "db_type": "character varying", + "default": "'a'::character varying", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_four", + "db_type": "character varying", + "default": "'b'::character varying", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_five", + "db_type": "character varying", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_six", + "db_type": "character varying", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_seven", + "db_type": "character varying", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_eight", + "db_type": "character varying", + "default": "'abcdefgh'::character varying", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_nine", + "db_type": "character varying", + "default": "'abcdefgh'::character varying", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_ten", + "db_type": "character varying", + "default": "''::character varying", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_eleven", + "db_type": "character varying", + "default": "''::character varying", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "nonbyte_zero", + "db_type": "character", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "nonbyte_one", + "db_type": "character", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "nonbyte_two", + "db_type": "character", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "nonbyte_three", + "db_type": "character", + "default": "'a'::bpchar", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "nonbyte_four", + "db_type": "character", + "default": "'b'::bpchar", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "nonbyte_five", + "db_type": "character", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "nonbyte_six", + "db_type": "character", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "nonbyte_seven", + "db_type": "character", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "nonbyte_eight", + "db_type": "character", + "default": "'a'::bpchar", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "nonbyte_nine", + "db_type": "character", + "default": "'b'::bpchar", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "byte_zero", + "db_type": "\"char\"", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "byte_one", + "db_type": "\"char\"", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "byte_two", + "db_type": "\"char\"", + "default": "'a'::\"char\"", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "byte_three", + "db_type": "\"char\"", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "byte_four", + "db_type": "\"char\"", + "default": "'b'::\"char\"", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "big_int_zero", + "db_type": "bigint", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_one", + "db_type": "bigint", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_two", + "db_type": "bigint", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_three", + "db_type": "bigint", + "default": "111111", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_four", + "db_type": "bigint", + "default": "222222", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_five", + "db_type": "bigint", + "default": "0", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_six", + "db_type": "bigint", + "default": "0", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "int_zero", + "db_type": "integer", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_one", + "db_type": "integer", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_two", + "db_type": "integer", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_three", + "db_type": "integer", + "default": "333333", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_four", + "db_type": "integer", + "default": "444444", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_five", + "db_type": "integer", + "default": "0", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_six", + "db_type": "integer", + "default": "0", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "float_zero", + "db_type": "numeric", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "float_one", + "db_type": "numeric", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "float_two", + "db_type": "numeric", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "float_three", + "db_type": "numeric", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "float_four", + "db_type": "numeric", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "float_five", + "db_type": "numeric", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "float_six", + "db_type": "numeric", + "default": "1.1", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "float_seven", + "db_type": "numeric", + "default": "1.1", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "float_eight", + "db_type": "numeric", + "default": "0.0", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "float_nine", + "db_type": "numeric", + "default": "0.0", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "bytea_zero", + "db_type": "bytea", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_one", + "db_type": "bytea", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_two", + "db_type": "bytea", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_three", + "db_type": "bytea", + "default": "'\\x61'::bytea", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_four", + "db_type": "bytea", + "default": "'\\x62'::bytea", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_five", + "db_type": "bytea", + "default": "'\\x616263646566676861626364656667686162636465666768'::bytea", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_six", + "db_type": "bytea", + "default": "'\\x686766656463626168676665646362616867666564636261'::bytea", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_seven", + "db_type": "bytea", + "default": "'\\x'::bytea", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_eight", + "db_type": "bytea", + "default": "'\\x'::bytea", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "time_zero", + "db_type": "timestamp without time zone", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_one", + "db_type": "date", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_two", + "db_type": "timestamp without time zone", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_three", + "db_type": "timestamp without time zone", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_four", + "db_type": "timestamp without time zone", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_five", + "db_type": "timestamp without time zone", + "default": "'1999-01-08 04:05:06.789'::timestamp without time zone", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_six", + "db_type": "timestamp without time zone", + "default": "'1999-01-08 04:05:06.789'::timestamp without time zone", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_seven", + "db_type": "timestamp without time zone", + "default": "'1999-01-08 04:05:06'::timestamp without time zone", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_eight", + "db_type": "timestamp without time zone", + "default": "'1999-01-08 04:05:06.789'::timestamp without time zone", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_nine", + "db_type": "timestamp without time zone", + "default": "'1999-01-08 04:05:06.789'::timestamp without time zone", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_ten", + "db_type": "timestamp without time zone", + "default": "'1999-01-08 04:05:06'::timestamp without time zone", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_eleven", + "db_type": "date", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_twelve", + "db_type": "date", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_thirteen", + "db_type": "date", + "default": "'1999-01-08'::date", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_fourteen", + "db_type": "date", + "default": "'1999-01-08'::date", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_fifteen", + "db_type": "date", + "default": "'1999-01-08'::date", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_sixteen", + "db_type": "date", + "default": "'1999-01-08'::date", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_seventeen", + "db_type": "date", + "default": "'1999-01-08'::date", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_eighteen", + "db_type": "date", + "default": "'1999-01-08'::date", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "uuid_zero", + "db_type": "uuid", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "uuid.UUID" + }, + { + "name": "uuid_one", + "db_type": "uuid", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "uuid.UUID" + }, + { + "name": "uuid_two", + "db_type": "uuid", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "uuid.UUID" + }, + { + "name": "uuid_three", + "db_type": "uuid", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "uuid.UUID" + }, + { + "name": "uuid_four", + "db_type": "uuid", + "default": "'6ba7b810-9dad-11d1-80b4-00c04fd430c8'::uuid", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "uuid.UUID" + }, + { + "name": "uuid_five", + "db_type": "uuid", + "default": "'6ba7b810-9dad-11d1-80b4-00c04fd430c8'::uuid", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "uuid.UUID" + }, + { + "name": "integer_default", + "db_type": "integer", + "default": "5", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "varchar_default", + "db_type": "character varying", + "default": "(5)::character varying", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "timestamp_notz", + "db_type": "timestamp without time zone", + "default": "(now() AT TIME ZONE 'utc'::text)", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "timestamp_tz", + "db_type": "timestamp with time zone", + "default": "(now() AT TIME ZONE 'utc'::text)", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "interval_nnull", + "db_type": "interval", + "default": "'21 days'::interval", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "interval_null", + "db_type": "interval", + "default": "'23:00:00'::interval", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "json_null", + "db_type": "json", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "types.JSON[json.RawMessage]" + }, + { + "name": "json_nnull", + "db_type": "json", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "types.JSON[json.RawMessage]" + }, + { + "name": "jsonb_null", + "db_type": "jsonb", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "types.JSON[json.RawMessage]" + }, + { + "name": "jsonb_nnull", + "db_type": "jsonb", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "types.JSON[json.RawMessage]" + }, + { + "name": "box_null", + "db_type": "box", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Box" + }, + { + "name": "box_nnull", + "db_type": "box", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Box" + }, + { + "name": "cidr_null", + "db_type": "cidr", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "types.Text[netip.Addr, *netip.Addr]" + }, + { + "name": "cidr_nnull", + "db_type": "cidr", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "types.Text[netip.Addr, *netip.Addr]" + }, + { + "name": "circle_null", + "db_type": "circle", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Circle" + }, + { + "name": "circle_nnull", + "db_type": "circle", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Circle" + }, + { + "name": "double_prec_null", + "db_type": "double precision", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float64" + }, + { + "name": "double_prec_nnull", + "db_type": "double precision", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float64" + }, + { + "name": "inet_null", + "db_type": "inet", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.Inet" + }, + { + "name": "inet_nnull", + "db_type": "inet", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.Inet" + }, + { + "name": "line_null", + "db_type": "line", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Line" + }, + { + "name": "line_nnull", + "db_type": "line", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Line" + }, + { + "name": "lseg_null", + "db_type": "lseg", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Lseg" + }, + { + "name": "lseg_nnull", + "db_type": "lseg", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Lseg" + }, + { + "name": "macaddr_null", + "db_type": "macaddr", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.Macaddr" + }, + { + "name": "macaddr_nnull", + "db_type": "macaddr", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.Macaddr" + }, + { + "name": "money_null", + "db_type": "money", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "money_nnull", + "db_type": "money", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "path_null", + "db_type": "path", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Path" + }, + { + "name": "path_nnull", + "db_type": "path", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Path" + }, + { + "name": "pg_lsn_null", + "db_type": "pg_lsn", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.LSN" + }, + { + "name": "pg_lsn_nnull", + "db_type": "pg_lsn", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.LSN" + }, + { + "name": "point_null", + "db_type": "point", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Point" + }, + { + "name": "point_nnull", + "db_type": "point", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Point" + }, + { + "name": "polygon_null", + "db_type": "polygon", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Polygon" + }, + { + "name": "polygon_nnull", + "db_type": "polygon", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Polygon" + }, + { + "name": "tsquery_null", + "db_type": "tsquery", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "tsquery_nnull", + "db_type": "tsquery", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "tsvector_null", + "db_type": "tsvector", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "tsvector_nnull", + "db_type": "tsvector", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "txid_null", + "db_type": "txid_snapshot", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.TxIDSnapshot" + }, + { + "name": "txid_nnull", + "db_type": "txid_snapshot", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.TxIDSnapshot" + }, + { + "name": "xml_null", + "db_type": "xml", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "xml" + }, + { + "name": "xml_nnull", + "db_type": "xml", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "xml" + }, + { + "name": "intarr_null", + "db_type": "integer[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.Int64Array" + }, + { + "name": "intarr_nnull", + "db_type": "integer[]", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.Int64Array" + }, + { + "name": "boolarr_null", + "db_type": "boolean[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.BoolArray" + }, + { + "name": "boolarr_nnull", + "db_type": "boolean[]", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.BoolArray" + }, + { + "name": "varchararr_null", + "db_type": "character varying[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.StringArray" + }, + { + "name": "varchararr_nnull", + "db_type": "character varying[]", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.StringArray" + }, + { + "name": "decimalarr_null", + "db_type": "numeric[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.Array[decimal.Decimal]" + }, + { + "name": "decimalarr_nnull", + "db_type": "numeric[]", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.Array[decimal.Decimal]" + }, + { + "name": "byteaarr_null", + "db_type": "bytea[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.ByteaArray" + }, + { + "name": "byteaarr_nnull", + "db_type": "bytea[]", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.ByteaArray" + }, + { + "name": "jsonbarr_null", + "db_type": "jsonb[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.StringArray" + }, + { + "name": "jsonbarr_nnull", + "db_type": "jsonb[]", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.StringArray" + }, + { + "name": "jsonarr_null", + "db_type": "json[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.StringArray" + }, + { + "name": "jsonarr_nnull", + "db_type": "json[]", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.StringArray" + }, + { + "name": "enumarr_null", + "db_type": "_unicode_enum[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.EnumArray[UnicodeEnum]" + }, + { + "name": "enumarr_nnull", + "db_type": "_unicode_enum[]", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.EnumArray[UnicodeEnum]" + }, + { + "name": "customarr_null", + "db_type": "_int4[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "my_int_array", + "type": "pq.Int64Array" + }, + { + "name": "customarr_nnull", + "db_type": "_int4[]", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "my_int_array", + "type": "pq.Int64Array" + }, + { + "name": "domainuint3_nnull", + "db_type": "numeric", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "uint3", + "type": "decimal.Decimal" + }, + { + "name": "base", + "db_type": "text", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "generated_nnull", + "db_type": "text", + "default": "GENERATED", + "comment": "", + "nullable": false, + "generated": true, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "generated_null", + "db_type": "text", + "default": "GENERATED", + "comment": "", + "nullable": true, + "generated": true, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "type_monsters_pkey", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "type_monsters_pkey", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "type_monsters_mv", + "schema": "", + "name": "type_monsters_mv", + "columns": null, + "indexes": null, + "constraints": { + "primary": null, + "foreign": null, + "uniques": null + } + }, + { + "key": "type_monsters_v", + "schema": "", + "name": "type_monsters_v", + "columns": [ + { + "name": "id", + "db_type": "integer", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "enum_use", + "db_type": "ENUM", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "UnicodeEnum" + }, + { + "name": "enum_nullable", + "db_type": "ENUM", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "UnicodeEnum" + }, + { + "name": "bool_zero", + "db_type": "boolean", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "bool_one", + "db_type": "boolean", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "bool_two", + "db_type": "boolean", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "bool_three", + "db_type": "boolean", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "bool_four", + "db_type": "boolean", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "bool_five", + "db_type": "boolean", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "bool_six", + "db_type": "boolean", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "string_zero", + "db_type": "character varying", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_one", + "db_type": "character varying", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_two", + "db_type": "character varying", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_three", + "db_type": "character varying", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_four", + "db_type": "character varying", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_five", + "db_type": "character varying", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_six", + "db_type": "character varying", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_seven", + "db_type": "character varying", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_eight", + "db_type": "character varying", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_nine", + "db_type": "character varying", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_ten", + "db_type": "character varying", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_eleven", + "db_type": "character varying", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "nonbyte_zero", + "db_type": "character", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "nonbyte_one", + "db_type": "character", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "nonbyte_two", + "db_type": "character", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "nonbyte_three", + "db_type": "character", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "nonbyte_four", + "db_type": "character", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "nonbyte_five", + "db_type": "character", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "nonbyte_six", + "db_type": "character", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "nonbyte_seven", + "db_type": "character", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "nonbyte_eight", + "db_type": "character", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "nonbyte_nine", + "db_type": "character", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "byte_zero", + "db_type": "\"char\"", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "byte_one", + "db_type": "\"char\"", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "byte_two", + "db_type": "\"char\"", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "byte_three", + "db_type": "\"char\"", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "byte_four", + "db_type": "\"char\"", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "big_int_zero", + "db_type": "bigint", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_one", + "db_type": "bigint", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_two", + "db_type": "bigint", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_three", + "db_type": "bigint", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_four", + "db_type": "bigint", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_five", + "db_type": "bigint", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_six", + "db_type": "bigint", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "int_zero", + "db_type": "integer", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_one", + "db_type": "integer", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_two", + "db_type": "integer", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_three", + "db_type": "integer", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_four", + "db_type": "integer", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_five", + "db_type": "integer", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_six", + "db_type": "integer", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "float_zero", + "db_type": "numeric", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "float_one", + "db_type": "numeric", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "float_two", + "db_type": "numeric", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "float_three", + "db_type": "numeric", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "float_four", + "db_type": "numeric", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "float_five", + "db_type": "numeric", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "float_six", + "db_type": "numeric", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "float_seven", + "db_type": "numeric", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "float_eight", + "db_type": "numeric", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "float_nine", + "db_type": "numeric", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "bytea_zero", + "db_type": "bytea", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_one", + "db_type": "bytea", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_two", + "db_type": "bytea", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_three", + "db_type": "bytea", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_four", + "db_type": "bytea", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_five", + "db_type": "bytea", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_six", + "db_type": "bytea", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_seven", + "db_type": "bytea", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "bytea_eight", + "db_type": "bytea", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "time_zero", + "db_type": "timestamp without time zone", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_one", + "db_type": "date", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_two", + "db_type": "timestamp without time zone", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_three", + "db_type": "timestamp without time zone", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_four", + "db_type": "timestamp without time zone", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_five", + "db_type": "timestamp without time zone", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_six", + "db_type": "timestamp without time zone", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_seven", + "db_type": "timestamp without time zone", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_eight", + "db_type": "timestamp without time zone", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_nine", + "db_type": "timestamp without time zone", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_ten", + "db_type": "timestamp without time zone", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_eleven", + "db_type": "date", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_twelve", + "db_type": "date", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_thirteen", + "db_type": "date", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_fourteen", + "db_type": "date", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_fifteen", + "db_type": "date", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_sixteen", + "db_type": "date", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_seventeen", + "db_type": "date", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_eighteen", + "db_type": "date", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "uuid_zero", + "db_type": "uuid", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "uuid.UUID" + }, + { + "name": "uuid_one", + "db_type": "uuid", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "uuid.UUID" + }, + { + "name": "uuid_two", + "db_type": "uuid", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "uuid.UUID" + }, + { + "name": "uuid_three", + "db_type": "uuid", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "uuid.UUID" + }, + { + "name": "uuid_four", + "db_type": "uuid", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "uuid.UUID" + }, + { + "name": "uuid_five", + "db_type": "uuid", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "uuid.UUID" + }, + { + "name": "integer_default", + "db_type": "integer", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "varchar_default", + "db_type": "character varying", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "timestamp_notz", + "db_type": "timestamp without time zone", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "timestamp_tz", + "db_type": "timestamp with time zone", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "interval_nnull", + "db_type": "interval", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "interval_null", + "db_type": "interval", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "json_null", + "db_type": "json", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "types.JSON[json.RawMessage]" + }, + { + "name": "json_nnull", + "db_type": "json", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "types.JSON[json.RawMessage]" + }, + { + "name": "jsonb_null", + "db_type": "jsonb", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "types.JSON[json.RawMessage]" + }, + { + "name": "jsonb_nnull", + "db_type": "jsonb", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "types.JSON[json.RawMessage]" + }, + { + "name": "box_null", + "db_type": "box", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Box" + }, + { + "name": "box_nnull", + "db_type": "box", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Box" + }, + { + "name": "cidr_null", + "db_type": "cidr", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "types.Text[netip.Addr, *netip.Addr]" + }, + { + "name": "cidr_nnull", + "db_type": "cidr", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "types.Text[netip.Addr, *netip.Addr]" + }, + { + "name": "circle_null", + "db_type": "circle", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Circle" + }, + { + "name": "circle_nnull", + "db_type": "circle", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Circle" + }, + { + "name": "double_prec_null", + "db_type": "double precision", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float64" + }, + { + "name": "double_prec_nnull", + "db_type": "double precision", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float64" + }, + { + "name": "inet_null", + "db_type": "inet", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.Inet" + }, + { + "name": "inet_nnull", + "db_type": "inet", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.Inet" + }, + { + "name": "line_null", + "db_type": "line", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Line" + }, + { + "name": "line_nnull", + "db_type": "line", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Line" + }, + { + "name": "lseg_null", + "db_type": "lseg", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Lseg" + }, + { + "name": "lseg_nnull", + "db_type": "lseg", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Lseg" + }, + { + "name": "macaddr_null", + "db_type": "macaddr", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.Macaddr" + }, + { + "name": "macaddr_nnull", + "db_type": "macaddr", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.Macaddr" + }, + { + "name": "money_null", + "db_type": "money", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "money_nnull", + "db_type": "money", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "decimal.Decimal" + }, + { + "name": "path_null", + "db_type": "path", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Path" + }, + { + "name": "path_nnull", + "db_type": "path", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Path" + }, + { + "name": "pg_lsn_null", + "db_type": "pg_lsn", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.LSN" + }, + { + "name": "pg_lsn_nnull", + "db_type": "pg_lsn", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.LSN" + }, + { + "name": "point_null", + "db_type": "point", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Point" + }, + { + "name": "point_nnull", + "db_type": "point", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Point" + }, + { + "name": "polygon_null", + "db_type": "polygon", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Polygon" + }, + { + "name": "polygon_nnull", + "db_type": "polygon", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgeo.Polygon" + }, + { + "name": "tsquery_null", + "db_type": "tsquery", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "tsquery_nnull", + "db_type": "tsquery", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "tsvector_null", + "db_type": "tsvector", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "tsvector_nnull", + "db_type": "tsvector", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "txid_null", + "db_type": "txid_snapshot", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.TxIDSnapshot" + }, + { + "name": "txid_nnull", + "db_type": "txid_snapshot", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.TxIDSnapshot" + }, + { + "name": "xml_null", + "db_type": "xml", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "xml" + }, + { + "name": "xml_nnull", + "db_type": "xml", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "xml" + }, + { + "name": "intarr_null", + "db_type": "integer[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.Int64Array" + }, + { + "name": "intarr_nnull", + "db_type": "integer[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.Int64Array" + }, + { + "name": "boolarr_null", + "db_type": "boolean[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.BoolArray" + }, + { + "name": "boolarr_nnull", + "db_type": "boolean[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.BoolArray" + }, + { + "name": "varchararr_null", + "db_type": "character varying[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.StringArray" + }, + { + "name": "varchararr_nnull", + "db_type": "character varying[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.StringArray" + }, + { + "name": "decimalarr_null", + "db_type": "numeric[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.Array[decimal.Decimal]" + }, + { + "name": "decimalarr_nnull", + "db_type": "numeric[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.Array[decimal.Decimal]" + }, + { + "name": "byteaarr_null", + "db_type": "bytea[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.ByteaArray" + }, + { + "name": "byteaarr_nnull", + "db_type": "bytea[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.ByteaArray" + }, + { + "name": "jsonbarr_null", + "db_type": "jsonb[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.StringArray" + }, + { + "name": "jsonbarr_nnull", + "db_type": "jsonb[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.StringArray" + }, + { + "name": "jsonarr_null", + "db_type": "json[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.StringArray" + }, + { + "name": "jsonarr_nnull", + "db_type": "json[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pq.StringArray" + }, + { + "name": "enumarr_null", + "db_type": "_unicode_enum[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.EnumArray[UnicodeEnum]" + }, + { + "name": "enumarr_nnull", + "db_type": "_unicode_enum[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "pgtypes.EnumArray[UnicodeEnum]" + }, + { + "name": "customarr_null", + "db_type": "_int4[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "my_int_array", + "type": "pq.Int64Array" + }, + { + "name": "customarr_nnull", + "db_type": "_int4[]", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "my_int_array", + "type": "pq.Int64Array" + }, + { + "name": "domainuint3_nnull", + "db_type": "numeric", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "uint3", + "type": "decimal.Decimal" + }, + { + "name": "base", + "db_type": "text", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "generated_nnull", + "db_type": "text", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "generated_null", + "db_type": "text", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": null, + "constraints": { + "primary": null, + "foreign": null, + "uniques": null + } + }, + { + "key": "user_videos", + "schema": "", + "name": "user_videos", + "columns": [ + { + "name": "user_id", + "db_type": "integer", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "video_id", + "db_type": "integer", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "sponsor_id", + "db_type": "integer", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": null, + "constraints": { + "primary": null, + "foreign": null, + "uniques": null + } + }, + { + "key": "users", + "schema": "", + "name": "users", + "columns": [ + { + "name": "id", + "db_type": "integer", + "default": "nextval('users_id_seq'::regclass)", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "email_validated", + "db_type": "boolean", + "default": "false", + "comment": "Has the email address been tested?", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "primary_email", + "db_type": "character varying", + "default": "NULL", + "comment": "The user's preferred email address.\n\nUse this to send emails to the user.", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "parent_id", + "db_type": "integer", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "party_id", + "db_type": "integer", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "referrer", + "db_type": "integer", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "users_party_id_key", + "columns": [ + "party_id" + ], + "expressions": null + }, + { + "name": "users_pkey", + "columns": [ + "id" + ], + "expressions": null + }, + { + "name": "users_primary_email_key", + "columns": [ + "primary_email" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "users_pkey", + "columns": [ + "id" + ] + }, + "foreign": [ + { + "name": "users.users_parent_id_fkey", + "columns": [ + "parent_id" + ], + "foreign_table": "users", + "foreign_columns": [ + "id" + ] + }, + { + "name": "users.users_party_id_fkey", + "columns": [ + "party_id" + ], + "foreign_table": "users", + "foreign_columns": [ + "id" + ] + }, + { + "name": "users.users_referrer_fkey", + "columns": [ + "referrer" + ], + "foreign_table": "users", + "foreign_columns": [ + "id" + ] + } + ], + "uniques": [ + { + "name": "users_party_id_key", + "columns": [ + "party_id" + ] + }, + { + "name": "users_primary_email_key", + "columns": [ + "primary_email" + ] + } + ] + } + }, + { + "key": "video_tags", + "schema": "", + "name": "video_tags", + "columns": [ + { + "name": "video_id", + "db_type": "integer", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "tag_id", + "db_type": "integer", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "video_tags_pkey", + "columns": [ + "video_id", + "tag_id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "video_tags_pkey", + "columns": [ + "video_id", + "tag_id" + ] + }, + "foreign": [ + { + "name": "video_tags.video_tags_tag_id_fkey", + "columns": [ + "tag_id" + ], + "foreign_table": "tags", + "foreign_columns": [ + "id" + ] + }, + { + "name": "video_tags.video_tags_video_id_fkey", + "columns": [ + "video_id" + ], + "foreign_table": "videos", + "foreign_columns": [ + "id" + ] + } + ], + "uniques": null + } + }, + { + "key": "videos", + "schema": "", + "name": "videos", + "columns": [ + { + "name": "id", + "db_type": "integer", + "default": "nextval('videos_id_seq'::regclass)", + "comment": "The ID of the video", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "user_id", + "db_type": "integer", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "sponsor_id", + "db_type": "integer", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "videos_pkey", + "columns": [ + "id" + ], + "expressions": null + }, + { + "name": "videos_sponsor_id_key", + "columns": [ + "sponsor_id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "videos_pkey", + "columns": [ + "id" + ] + }, + "foreign": [ + { + "name": "videos.videos_sponsor_id_fkey", + "columns": [ + "sponsor_id" + ], + "foreign_table": "sponsors", + "foreign_columns": [ + "id" + ] + }, + { + "name": "videos.videos_user_id_fkey", + "columns": [ + "user_id" + ], + "foreign_table": "users", + "foreign_columns": [ + "id" + ] + } + ], + "uniques": [ + { + "name": "videos_sponsor_id_key", + "columns": [ + "sponsor_id" + ] + } + ] + } + } + ], + "enums": [ + { + "Type": "UnicodeEnum", + "Values": [ + "hello", + "привет", + "こんにちは", + "안녕하세요", + "hello_with_underscore" + ] + } + ], + "extra_info": null, + "driver_name": "github.com/lib/pq" +} \ No newline at end of file diff --git a/gen/bobgen-psql/driver/include-exclude-tables-mixed.golden.json b/gen/bobgen-psql/driver/include-exclude-tables-mixed.golden.json new file mode 100644 index 00000000..ec4b821b --- /dev/null +++ b/gen/bobgen-psql/driver/include-exclude-tables-mixed.golden.json @@ -0,0 +1,114 @@ +{ + "tables": [ + { + "key": "bar_baz", + "schema": "", + "name": "bar_baz", + "columns": [ + { + "name": "id", + "db_type": "integer", + "default": "nextval('bar_baz_id_seq'::regclass)", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "character varying", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "bar_baz_pkey", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "bar_baz_pkey", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "bar_qux", + "schema": "", + "name": "bar_qux", + "columns": [ + { + "name": "id", + "db_type": "integer", + "default": "nextval('bar_qux_id_seq'::regclass)", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "character varying", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "bar_qux_pkey", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "bar_qux_pkey", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + } + ], + "enums": [ + { + "Type": "UnicodeEnum", + "Values": [ + "hello", + "привет", + "こんにちは", + "안녕하세요", + "hello_with_underscore" + ] + } + ], + "extra_info": null, + "driver_name": "github.com/lib/pq" +} \ No newline at end of file diff --git a/gen/bobgen-psql/driver/include-exclude-tables-regex.golden.json b/gen/bobgen-psql/driver/include-exclude-tables-regex.golden.json new file mode 100644 index 00000000..352eb706 --- /dev/null +++ b/gen/bobgen-psql/driver/include-exclude-tables-regex.golden.json @@ -0,0 +1,114 @@ +{ + "tables": [ + { + "key": "bar_qux", + "schema": "", + "name": "bar_qux", + "columns": [ + { + "name": "id", + "db_type": "integer", + "default": "nextval('bar_qux_id_seq'::regclass)", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "character varying", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "bar_qux_pkey", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "bar_qux_pkey", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "foo_qux", + "schema": "", + "name": "foo_qux", + "columns": [ + { + "name": "id", + "db_type": "integer", + "default": "nextval('foo_qux_id_seq'::regclass)", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "character varying", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "foo_qux_pkey", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "foo_qux_pkey", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + } + ], + "enums": [ + { + "Type": "UnicodeEnum", + "Values": [ + "hello", + "привет", + "こんにちは", + "안녕하세요", + "hello_with_underscore" + ] + } + ], + "extra_info": null, + "driver_name": "github.com/lib/pq" +} \ No newline at end of file diff --git a/gen/bobgen-psql/driver/include-exclude-tables.golden.json b/gen/bobgen-psql/driver/include-exclude-tables.golden.json new file mode 100644 index 00000000..94107b1f --- /dev/null +++ b/gen/bobgen-psql/driver/include-exclude-tables.golden.json @@ -0,0 +1,66 @@ +{ + "tables": [ + { + "key": "foo_baz", + "schema": "", + "name": "foo_baz", + "columns": [ + { + "name": "id", + "db_type": "integer", + "default": "nextval('foo_baz_id_seq'::regclass)", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "character varying", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "foo_baz_pkey", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "foo_baz_pkey", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + } + ], + "enums": [ + { + "Type": "UnicodeEnum", + "Values": [ + "hello", + "привет", + "こんにちは", + "안녕하세요", + "hello_with_underscore" + ] + } + ], + "extra_info": null, + "driver_name": "github.com/lib/pq" +} \ No newline at end of file diff --git a/gen/bobgen-psql/driver/include-tables.golden.json b/gen/bobgen-psql/driver/include-tables.golden.json new file mode 100644 index 00000000..9044b37d --- /dev/null +++ b/gen/bobgen-psql/driver/include-tables.golden.json @@ -0,0 +1,114 @@ +{ + "tables": [ + { + "key": "foo_bar", + "schema": "", + "name": "foo_bar", + "columns": [ + { + "name": "id", + "db_type": "integer", + "default": "nextval('foo_bar_id_seq'::regclass)", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "character varying", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "foo_bar_pkey", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "foo_bar_pkey", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "foo_baz", + "schema": "", + "name": "foo_baz", + "columns": [ + { + "name": "id", + "db_type": "integer", + "default": "nextval('foo_baz_id_seq'::regclass)", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "character varying", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "foo_baz_pkey", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "foo_baz_pkey", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + } + ], + "enums": [ + { + "Type": "UnicodeEnum", + "Values": [ + "hello", + "привет", + "こんにちは", + "안녕하세요", + "hello_with_underscore" + ] + } + ], + "extra_info": null, + "driver_name": "github.com/lib/pq" +} \ No newline at end of file diff --git a/gen/bobgen-psql/driver/psql.go b/gen/bobgen-psql/driver/psql.go index 864643c8..b7a52527 100644 --- a/gen/bobgen-psql/driver/psql.go +++ b/gen/bobgen-psql/driver/psql.go @@ -6,6 +6,7 @@ import ( "fmt" "regexp" "sort" + "strings" "github.com/lib/pq" helpers "github.com/stephenafamo/bob/gen/bobgen-helpers" @@ -195,17 +196,35 @@ func (d *driver) TablesInfo(ctx context.Context, tableFilter drivers.Filter) (dr exclude := tableFilter.Except if len(include) > 0 { - query += fmt.Sprintf(" and %s in (%s)", keyClause, strmangle.Placeholders(true, len(include), 3, 1)) - for _, w := range include { - args = append(args, w) + var subqueries []string + stringPatterns, regexPatterns := tableFilter.ClassifyPatterns(include) + if len(stringPatterns) > 0 { + subqueries = append(subqueries, fmt.Sprintf("%s in (%s)", keyClause, strmangle.Placeholders(true, len(stringPatterns), len(args)+1, 1))) + for _, w := range stringPatterns { + args = append(args, w) + } + } + if len(regexPatterns) > 0 { + subqueries = append(subqueries, fmt.Sprintf("%s ~ (%s)", keyClause, strmangle.Placeholders(true, 1, len(args)+1, 1))) + args = append(args, strings.Join(regexPatterns, "|")) } + query += fmt.Sprintf(" and (%s)", strings.Join(subqueries, " or ")) } if len(exclude) > 0 { - query += fmt.Sprintf(" and %s not in (%s)", keyClause, strmangle.Placeholders(true, len(exclude), 3+len(include), 1)) - for _, w := range exclude { - args = append(args, w) + var subqueries []string + stringPatterns, regexPatterns := tableFilter.ClassifyPatterns(exclude) + if len(stringPatterns) > 0 { + subqueries = append(subqueries, fmt.Sprintf("%s not in (%s)", keyClause, strmangle.Placeholders(true, len(stringPatterns), len(args)+1, 1))) + for _, w := range stringPatterns { + args = append(args, w) + } + } + if len(regexPatterns) > 0 { + subqueries = append(subqueries, fmt.Sprintf("%s !~ (%s)", keyClause, strmangle.Placeholders(true, 1, len(args)+1, 1))) + args = append(args, strings.Join(regexPatterns, "|")) } + query += fmt.Sprintf(" and (%s)", strings.Join(subqueries, " and ")) } query += ` order by table_name;` diff --git a/gen/bobgen-psql/driver/psql.golden.json b/gen/bobgen-psql/driver/psql.golden.json index f40b1efe..0aa2aeaf 100644 --- a/gen/bobgen-psql/driver/psql.golden.json +++ b/gen/bobgen-psql/driver/psql.golden.json @@ -1,5 +1,245 @@ { "tables": [ + { + "key": "bar_baz", + "schema": "", + "name": "bar_baz", + "columns": [ + { + "name": "id", + "db_type": "integer", + "default": "nextval('bar_baz_id_seq'::regclass)", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "character varying", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "bar_baz_pkey", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "bar_baz_pkey", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "bar_qux", + "schema": "", + "name": "bar_qux", + "columns": [ + { + "name": "id", + "db_type": "integer", + "default": "nextval('bar_qux_id_seq'::regclass)", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "character varying", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "bar_qux_pkey", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "bar_qux_pkey", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "foo_bar", + "schema": "", + "name": "foo_bar", + "columns": [ + { + "name": "id", + "db_type": "integer", + "default": "nextval('foo_bar_id_seq'::regclass)", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "character varying", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "foo_bar_pkey", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "foo_bar_pkey", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "foo_baz", + "schema": "", + "name": "foo_baz", + "columns": [ + { + "name": "id", + "db_type": "integer", + "default": "nextval('foo_baz_id_seq'::regclass)", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "character varying", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "foo_baz_pkey", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "foo_baz_pkey", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, + { + "key": "foo_qux", + "schema": "", + "name": "foo_qux", + "columns": [ + { + "name": "id", + "db_type": "integer", + "default": "nextval('foo_qux_id_seq'::regclass)", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "character varying", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "foo_qux_pkey", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "foo_qux_pkey", + "columns": [ + "id" + ] + }, + "foreign": null, + "uniques": null + } + }, { "key": "sponsors", "schema": "", diff --git a/gen/bobgen-psql/driver/psql_test.go b/gen/bobgen-psql/driver/psql_test.go index 4eb6535d..173e4a23 100644 --- a/gen/bobgen-psql/driver/psql_test.go +++ b/gen/bobgen-psql/driver/psql_test.go @@ -69,6 +69,76 @@ func TestDriver(t *testing.T) { }, goldenJson: "psql.golden.json", }, + { + name: "include tables", + config: Config{ + Dsn: dsn, + Only: map[string][]string{ + "foo_bar": nil, + "foo_baz": nil, + }, + }, + goldenJson: "include-tables.golden.json", + }, + { + name: "exclude tables", + config: Config{ + Dsn: dsn, + Except: map[string][]string{ + "foo_bar": nil, + "foo_baz": nil, + "*": {"secret_col"}, + }, + }, + goldenJson: "exclude-tables.golden.json", + }, + { + name: "include + exclude tables", + config: Config{ + Dsn: dsn, + Only: map[string][]string{ + "foo_bar": nil, + "foo_baz": nil, + }, + Except: map[string][]string{ + "foo_bar": nil, + "bar_baz": nil, + }, + }, + goldenJson: "include-exclude-tables.golden.json", + }, + { + name: "include + exclude tables regex", + config: Config{ + Dsn: dsn, + Only: map[string][]string{ + "/^foo/": nil, + "/^bar/": nil, + }, + Except: map[string][]string{ + "/bar$/": nil, + "/baz$/": nil, + }, + }, + goldenJson: "include-exclude-tables-regex.golden.json", + }, + { + name: "include + exclude tables mixed", + config: Config{ + Dsn: dsn, + Only: map[string][]string{ + "/^foo/": nil, + "bar_baz": nil, + "bar_qux": nil, + }, + Except: map[string][]string{ + "/bar$/": nil, + "foo_baz": nil, + "foo_qux": nil, + }, + }, + goldenJson: "include-exclude-tables-mixed.golden.json", + }, } for _, tt := range tests { diff --git a/gen/bobgen-sqlite/driver/exclude-tables.golden.json b/gen/bobgen-sqlite/driver/exclude-tables.golden.json new file mode 100644 index 00000000..b7e91a2a --- /dev/null +++ b/gen/bobgen-sqlite/driver/exclude-tables.golden.json @@ -0,0 +1,2575 @@ +{ + "tables": [ + { + "key": "autoinckeywordtest", + "schema": "", + "name": "autoinckeywordtest", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "user_id", + "db_type": "INT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "sponsor_id", + "db_type": "INT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "something", + "db_type": "TEXT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "another", + "db_type": "TEXT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "sqlite_autoindex_autoinckeywordtest_1", + "columns": [ + "sponsor_id" + ], + "expressions": null + }, + { + "name": "sqlite_autoindex_autoinckeywordtest_2", + "columns": [ + "something", + "another" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "pk_main_autoinckeywordtest", + "columns": [ + "id" + ] + }, + "foreign": [ + { + "name": "fk_autoinckeywordtest_0", + "columns": [ + "user_id", + "sponsor_id" + ], + "foreign_table": "videos", + "foreign_columns": [ + "user_id", + "sponsor_id" + ] + } + ], + "uniques": [ + { + "name": "sqlite_autoindex_autoinckeywordtest_2", + "columns": [ + "something", + "another" + ] + }, + { + "name": "sqlite_autoindex_autoinckeywordtest_1", + "columns": [ + "sponsor_id" + ] + } + ] + } + }, + { + "key": "autoinctest", + "schema": "", + "name": "autoinctest", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_main_autoinctest", + "columns": [ + "id" + ] + }, + "foreign": [ + { + "name": "fk_autoinctest_0", + "columns": [ + "id" + ], + "foreign_table": "tags", + "foreign_columns": [ + "id" + ] + } + ], + "uniques": [] + } + }, + { + "key": "bar_baz", + "schema": "", + "name": "bar_baz", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_main_bar_baz", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "bar_qux", + "schema": "", + "name": "bar_qux", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_main_bar_qux", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "foo_qux", + "schema": "", + "name": "foo_qux", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_main_foo_qux", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "has_generated_columns", + "schema": "", + "name": "has_generated_columns", + "columns": [ + { + "name": "a", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "b", + "db_type": "INT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "c", + "db_type": "TEXT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "d", + "db_type": "INT", + "default": "auto_generated", + "comment": "", + "nullable": true, + "generated": true, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "e", + "db_type": "TEXT", + "default": "auto_generated", + "comment": "", + "nullable": true, + "generated": true, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_main_has_generated_columns", + "columns": [ + "a" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.as_generated_columns", + "schema": "one", + "name": "as_generated_columns", + "columns": [ + { + "name": "a", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "b", + "db_type": "INT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "c", + "db_type": "TEXT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "d", + "db_type": "INT", + "default": "auto_generated", + "comment": "", + "nullable": true, + "generated": true, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "e", + "db_type": "TEXT", + "default": "auto_generated", + "comment": "", + "nullable": true, + "generated": true, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_one_as_generated_columns", + "columns": [ + "a" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.autoinckeywordtest", + "schema": "one", + "name": "autoinckeywordtest", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "b", + "db_type": "INTEGER", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "sqlite_autoindex_autoinckeywordtest_1", + "columns": [ + "sponsor_id" + ], + "expressions": null + }, + { + "name": "sqlite_autoindex_autoinckeywordtest_2", + "columns": [ + "something", + "another" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "pk_one_autoinckeywordtest", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.autoinctest", + "schema": "one", + "name": "autoinctest", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_one_autoinctest", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.bar_baz", + "schema": "one", + "name": "bar_baz", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_one_bar_baz", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.bar_qux", + "schema": "one", + "name": "bar_qux", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_one_bar_qux", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.foo_qux", + "schema": "one", + "name": "foo_qux", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_one_foo_qux", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.sponsors", + "schema": "one", + "name": "sponsors", + "columns": [ + { + "name": "id", + "db_type": "INT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "sqlite_autoindex_sponsors_1", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "pk_one_sponsors", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.tags", + "schema": "one", + "name": "tags", + "columns": [ + { + "name": "id", + "db_type": "INT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "sqlite_autoindex_tags_1", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "pk_one_tags", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.user_videos", + "schema": "one", + "name": "user_videos", + "columns": [ + { + "name": "user_id", + "db_type": "INT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "video_id", + "db_type": "INT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "sponsor_id", + "db_type": "INT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [], + "constraints": { + "primary": null, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.users", + "schema": "one", + "name": "users", + "columns": [ + { + "name": "id", + "db_type": "INT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "sqlite_autoindex_users_1", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "pk_one_users", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.video_tags", + "schema": "one", + "name": "video_tags", + "columns": [ + { + "name": "video_id", + "db_type": "INT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "tag_id", + "db_type": "INT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "sqlite_autoindex_video_tags_1", + "columns": [ + "video_id", + "tag_id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "pk_one_video_tags", + "columns": [ + "video_id", + "tag_id" + ] + }, + "foreign": [ + { + "name": "fk_video_tags_0", + "columns": [ + "tag_id" + ], + "foreign_table": "one.tags", + "foreign_columns": [ + "id" + ] + }, + { + "name": "fk_video_tags_1", + "columns": [ + "video_id" + ], + "foreign_table": "one.videos", + "foreign_columns": [ + "id" + ] + } + ], + "uniques": [] + } + }, + { + "key": "one.videos", + "schema": "one", + "name": "videos", + "columns": [ + { + "name": "id", + "db_type": "INT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "user_id", + "db_type": "INT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "sponsor_id", + "db_type": "INT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "sqlite_autoindex_videos_1", + "columns": [ + "id" + ], + "expressions": null + }, + { + "name": "sqlite_autoindex_videos_2", + "columns": [ + "sponsor_id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "pk_one_videos", + "columns": [ + "id" + ] + }, + "foreign": [ + { + "name": "fk_videos_0", + "columns": [ + "sponsor_id" + ], + "foreign_table": "one.sponsors", + "foreign_columns": [ + "id" + ] + }, + { + "name": "fk_videos_1", + "columns": [ + "user_id" + ], + "foreign_table": "one.users", + "foreign_columns": [ + "id" + ] + } + ], + "uniques": [ + { + "name": "sqlite_autoindex_videos_2", + "columns": [ + "sponsor_id" + ] + } + ] + } + }, + { + "key": "sponsors", + "schema": "", + "name": "sponsors", + "columns": [ + { + "name": "id", + "db_type": "INT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "sqlite_autoindex_sponsors_1", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "pk_main_sponsors", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "tags", + "schema": "", + "name": "tags", + "columns": [ + { + "name": "id", + "db_type": "INT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "sqlite_autoindex_tags_1", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "pk_main_tags", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "test_index_expressions", + "schema": "", + "name": "test_index_expressions", + "columns": [ + { + "name": "col1", + "db_type": "INT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "col2", + "db_type": "INT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "col3", + "db_type": "INT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "idx1", + "columns": null, + "expressions": [ + "(col1 + col2)" + ] + }, + { + "name": "idx2", + "columns": [ + "col3" + ], + "expressions": [ + "(col1 + col2)" + ] + }, + { + "name": "idx3", + "columns": [ + "col1" + ], + "expressions": [ + "(col2 + col3)" + ] + }, + { + "name": "idx4", + "columns": [ + "col3" + ], + "expressions": null + }, + { + "name": "idx5", + "columns": [ + "col1", + "col2" + ], + "expressions": null + }, + { + "name": "idx6", + "columns": null, + "expressions": [ + "POW(col3, 2)" + ] + } + ], + "constraints": { + "primary": null, + "foreign": [], + "uniques": [] + } + }, + { + "key": "type_monsters", + "schema": "", + "name": "type_monsters", + "columns": [ + { + "name": "id", + "db_type": "INT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "id_two", + "db_type": "INT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "id_three", + "db_type": "INT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "bool_zero", + "db_type": "BOOL", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "bool_one", + "db_type": "BOOL", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "bool_two", + "db_type": "BOOL", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "bool_three", + "db_type": "BOOL", + "default": "false", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "bool_four", + "db_type": "BOOL", + "default": "true", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "bool_five", + "db_type": "BOOL", + "default": "false", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "bool_six", + "db_type": "BOOL", + "default": "true", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_zero", + "db_type": "VARCHAR(1)", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_one", + "db_type": "VARCHAR(1)", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_two", + "db_type": "VARCHAR(1)", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_three", + "db_type": "VARCHAR(1)", + "default": "'a'", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_four", + "db_type": "VARCHAR(1)", + "default": "'b'", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_five", + "db_type": "VARCHAR(1000)", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_six", + "db_type": "VARCHAR(1000)", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_seven", + "db_type": "VARCHAR(1000)", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_eight", + "db_type": "VARCHAR(1000)", + "default": "'abcdefgh'", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_nine", + "db_type": "VARCHAR(1000)", + "default": "'abcdefgh'", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_ten", + "db_type": "VARCHAR(1000)", + "default": "''", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "string_eleven", + "db_type": "VARCHAR(1000)", + "default": "''", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "big_int_zero", + "db_type": "BIGINT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_one", + "db_type": "BIGINT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_two", + "db_type": "BIGINT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_three", + "db_type": "BIGINT", + "default": "111111", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_four", + "db_type": "BIGINT", + "default": "222222", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_five", + "db_type": "BIGINT", + "default": "0", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "big_int_six", + "db_type": "BIGINT", + "default": "0", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "int_zero", + "db_type": "INT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_one", + "db_type": "INT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_two", + "db_type": "INT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_three", + "db_type": "INT", + "default": "333333", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_four", + "db_type": "INT", + "default": "444444", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_five", + "db_type": "INT", + "default": "0", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "int_six", + "db_type": "INT", + "default": "0", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "float_zero", + "db_type": "FLOAT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float32" + }, + { + "name": "float_one", + "db_type": "FLOAT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float32" + }, + { + "name": "float_two", + "db_type": "FLOAT(2,1)", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "float_three", + "db_type": "FLOAT(2,1)", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "float_four", + "db_type": "FLOAT(2,1)", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "float_five", + "db_type": "FLOAT(2,1)", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "float_six", + "db_type": "FLOAT(2,1)", + "default": "1.1", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "float_seven", + "db_type": "FLOAT(2,1)", + "default": "1.1", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "float_eight", + "db_type": "FLOAT(2,1)", + "default": "0.0", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "float_nine", + "db_type": "FLOAT(2,1)", + "default": "0.0", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "bytea_zero", + "db_type": "BINARY", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "bytea_one", + "db_type": "BINARY", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "bytea_two", + "db_type": "BINARY", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "bytea_three", + "db_type": "BINARY", + "default": "'a'", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "bytea_four", + "db_type": "BINARY", + "default": "'b'", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "bytea_five", + "db_type": "BINARY(100)", + "default": "'abcdefghabcdefghabcdefgh'", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "bytea_six", + "db_type": "BINARY(100)", + "default": "'hgfedcbahgfedcbahgfedcba'", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "bytea_seven", + "db_type": "BINARY", + "default": "''", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "bytea_eight", + "db_type": "BINARY", + "default": "''", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "time_zero", + "db_type": "TIMESTAMP", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "time_one", + "db_type": "DATE", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_two", + "db_type": "TIMESTAMP", + "default": "null", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "time_three", + "db_type": "TIMESTAMP", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "time_five", + "db_type": "TIMESTAMP", + "default": "current_timestamp", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "time_nine", + "db_type": "TIMESTAMP", + "default": "current_timestamp", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "time_eleven", + "db_type": "DATE", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_twelve", + "db_type": "DATE", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_fifteen", + "db_type": "DATE", + "default": "'19990108'", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "time_sixteen", + "db_type": "DATE", + "default": "'1999-01-08'", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "json_null", + "db_type": "JSON", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "types.JSON[json.RawMessage]" + }, + { + "name": "json_nnull", + "db_type": "JSON", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "types.JSON[json.RawMessage]" + }, + { + "name": "tinyint_null", + "db_type": "TINYINT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int8" + }, + { + "name": "tinyint_nnull", + "db_type": "TINYINT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int8" + }, + { + "name": "tinyint1_null", + "db_type": "TINYINT(1)", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "tinyint1_nnull", + "db_type": "TINYINT(1)", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "tinyint2_null", + "db_type": "TINYINT(2)", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "tinyint2_nnull", + "db_type": "TINYINT(2)", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "smallint_null", + "db_type": "SMALLINT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int16" + }, + { + "name": "smallint_nnull", + "db_type": "SMALLINT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int16" + }, + { + "name": "mediumint_null", + "db_type": "MEDIUMINT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "mediumint_nnull", + "db_type": "MEDIUMINT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "bigint_null", + "db_type": "BIGINT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "bigint_nnull", + "db_type": "BIGINT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int64" + }, + { + "name": "float_null", + "db_type": "FLOAT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float32" + }, + { + "name": "float_nnull", + "db_type": "FLOAT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float32" + }, + { + "name": "double_null", + "db_type": "DOUBLE", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float64" + }, + { + "name": "double_nnull", + "db_type": "DOUBLE", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float64" + }, + { + "name": "doubleprec_null", + "db_type": "DOUBLE PRECISION", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float64" + }, + { + "name": "doubleprec_nnull", + "db_type": "DOUBLE PRECISION", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float64" + }, + { + "name": "real_null", + "db_type": "REAL", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float32" + }, + { + "name": "real_nnull", + "db_type": "REAL", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "float32" + }, + { + "name": "boolean_null", + "db_type": "BOOLEAN", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "boolean_nnull", + "db_type": "BOOLEAN", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "bool" + }, + { + "name": "date_null", + "db_type": "DATE", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "date_nnull", + "db_type": "DATE", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "datetime_null", + "db_type": "DATETIME", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "datetime_nnull", + "db_type": "DATETIME", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "time.Time" + }, + { + "name": "timestamp_null", + "db_type": "TIMESTAMP", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "timestamp_nnull", + "db_type": "TIMESTAMP", + "default": "current_timestamp", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "binary_null", + "db_type": "BINARY", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "binary_nnull", + "db_type": "BINARY", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "varbinary_null", + "db_type": "VARBINARY(100)", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "varbinary_nnull", + "db_type": "VARBINARY(100)", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "tinyblob_null", + "db_type": "TINYBLOB", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "tinyblob_nnull", + "db_type": "TINYBLOB", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "blob_null", + "db_type": "BLOB", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "blob_nnull", + "db_type": "BLOB", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "[]byte" + }, + { + "name": "mediumblob_null", + "db_type": "MEDIUMBLOB", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "mediumblob_nnull", + "db_type": "MEDIUMBLOB", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "longblob_null", + "db_type": "LONGBLOB", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "longblob_nnull", + "db_type": "LONGBLOB", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "varchar_null", + "db_type": "VARCHAR(100)", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "varchar_nnull", + "db_type": "VARCHAR(100)", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "char_null", + "db_type": "CHAR", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "char_nnull", + "db_type": "CHAR", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "text_null", + "db_type": "TEXT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + }, + { + "name": "text_nnull", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [ + { + "name": "sqlite_autoindex_type_monsters_1", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "pk_main_type_monsters", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "user_videos", + "schema": "", + "name": "user_videos", + "columns": [ + { + "name": "user_id", + "db_type": "INT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "video_id", + "db_type": "INT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "sponsor_id", + "db_type": "INT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [], + "constraints": { + "primary": null, + "foreign": [], + "uniques": [] + } + }, + { + "key": "users", + "schema": "", + "name": "users", + "columns": [ + { + "name": "id", + "db_type": "INT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "sqlite_autoindex_users_1", + "columns": [ + "id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "pk_main_users", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "video_tags", + "schema": "", + "name": "video_tags", + "columns": [ + { + "name": "video_id", + "db_type": "INT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "tag_id", + "db_type": "INT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "sqlite_autoindex_video_tags_1", + "columns": [ + "video_id", + "tag_id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "pk_main_video_tags", + "columns": [ + "video_id", + "tag_id" + ] + }, + "foreign": [ + { + "name": "fk_video_tags_0", + "columns": [ + "tag_id" + ], + "foreign_table": "tags", + "foreign_columns": [ + "id" + ] + }, + { + "name": "fk_video_tags_1", + "columns": [ + "video_id" + ], + "foreign_table": "videos", + "foreign_columns": [ + "id" + ] + } + ], + "uniques": [] + } + }, + { + "key": "videos", + "schema": "", + "name": "videos", + "columns": [ + { + "name": "id", + "db_type": "INT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "user_id", + "db_type": "INT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "sponsor_id", + "db_type": "INT", + "default": "NULL", + "comment": "", + "nullable": true, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + } + ], + "indexes": [ + { + "name": "sqlite_autoindex_videos_1", + "columns": [ + "id" + ], + "expressions": null + }, + { + "name": "sqlite_autoindex_videos_2", + "columns": [ + "sponsor_id" + ], + "expressions": null + } + ], + "constraints": { + "primary": { + "name": "pk_main_videos", + "columns": [ + "id" + ] + }, + "foreign": [ + { + "name": "fk_videos_0", + "columns": [ + "sponsor_id" + ], + "foreign_table": "sponsors", + "foreign_columns": [ + "id" + ] + }, + { + "name": "fk_videos_1", + "columns": [ + "user_id" + ], + "foreign_table": "users", + "foreign_columns": [ + "id" + ] + } + ], + "uniques": [ + { + "name": "sqlite_autoindex_videos_2", + "columns": [ + "sponsor_id" + ] + } + ] + } + } + ], + "enums": null, + "extra_info": null, + "driver_name": "modernc.org/sqlite" +} \ No newline at end of file diff --git a/gen/bobgen-sqlite/driver/include-exclude-tables-mixed.golden.json b/gen/bobgen-sqlite/driver/include-exclude-tables-mixed.golden.json new file mode 100644 index 00000000..f9832822 --- /dev/null +++ b/gen/bobgen-sqlite/driver/include-exclude-tables-mixed.golden.json @@ -0,0 +1,167 @@ +{ + "tables": [ + { + "key": "bar_baz", + "schema": "", + "name": "bar_baz", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_main_bar_baz", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "bar_qux", + "schema": "", + "name": "bar_qux", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_main_bar_qux", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.bar_baz", + "schema": "one", + "name": "bar_baz", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_one_bar_baz", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.bar_qux", + "schema": "one", + "name": "bar_qux", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_one_bar_qux", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + } + ], + "enums": null, + "extra_info": null, + "driver_name": "modernc.org/sqlite" +} \ No newline at end of file diff --git a/gen/bobgen-sqlite/driver/include-exclude-tables-regex.golden.json b/gen/bobgen-sqlite/driver/include-exclude-tables-regex.golden.json new file mode 100644 index 00000000..fea63555 --- /dev/null +++ b/gen/bobgen-sqlite/driver/include-exclude-tables-regex.golden.json @@ -0,0 +1,167 @@ +{ + "tables": [ + { + "key": "bar_qux", + "schema": "", + "name": "bar_qux", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_main_bar_qux", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "foo_qux", + "schema": "", + "name": "foo_qux", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_main_foo_qux", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.bar_qux", + "schema": "one", + "name": "bar_qux", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_one_bar_qux", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.foo_qux", + "schema": "one", + "name": "foo_qux", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_one_foo_qux", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + } + ], + "enums": null, + "extra_info": null, + "driver_name": "modernc.org/sqlite" +} \ No newline at end of file diff --git a/gen/bobgen-sqlite/driver/include-exclude-tables.golden.json b/gen/bobgen-sqlite/driver/include-exclude-tables.golden.json new file mode 100644 index 00000000..e5ae14ec --- /dev/null +++ b/gen/bobgen-sqlite/driver/include-exclude-tables.golden.json @@ -0,0 +1,87 @@ +{ + "tables": [ + { + "key": "foo_baz", + "schema": "", + "name": "foo_baz", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_main_foo_baz", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.foo_baz", + "schema": "one", + "name": "foo_baz", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_one_foo_baz", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + } + ], + "enums": null, + "extra_info": null, + "driver_name": "modernc.org/sqlite" +} \ No newline at end of file diff --git a/gen/bobgen-sqlite/driver/include-tables.golden.json b/gen/bobgen-sqlite/driver/include-tables.golden.json new file mode 100644 index 00000000..a5178771 --- /dev/null +++ b/gen/bobgen-sqlite/driver/include-tables.golden.json @@ -0,0 +1,167 @@ +{ + "tables": [ + { + "key": "foo_bar", + "schema": "", + "name": "foo_bar", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_main_foo_bar", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "foo_baz", + "schema": "", + "name": "foo_baz", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_main_foo_baz", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.foo_bar", + "schema": "one", + "name": "foo_bar", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_one_foo_bar", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.foo_baz", + "schema": "one", + "name": "foo_baz", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_one_foo_baz", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + } + ], + "enums": null, + "extra_info": null, + "driver_name": "modernc.org/sqlite" +} \ No newline at end of file diff --git a/gen/bobgen-sqlite/driver/sqlite.go b/gen/bobgen-sqlite/driver/sqlite.go index 4b066ead..6612cbc0 100644 --- a/gen/bobgen-sqlite/driver/sqlite.go +++ b/gen/bobgen-sqlite/driver/sqlite.go @@ -125,31 +125,51 @@ func (d *driver) buildQuery(schema string) (string, []any) { tableFilter := drivers.ParseTableFilter(d.config.Only, d.config.Except) - include := make([]string, 0, len(tableFilter.Only)) - for _, name := range tableFilter.Only { - if (schema == "main" && !strings.Contains(name, ".")) || strings.HasPrefix(name, schema+".") { - include = append(include, name) + if len(tableFilter.Only) > 0 { + var subqueries []string + stringPatterns, regexPatterns := tableFilter.ClassifyPatterns(tableFilter.Only) + include := make([]string, 0, len(stringPatterns)) + for _, name := range stringPatterns { + if (schema == "main" && !strings.Contains(name, ".")) || strings.HasPrefix(name, schema+".") { + include = append(include, strings.TrimPrefix(name, schema+".")) + } } - } - - exclude := make([]string, 0, len(tableFilter.Except)) - for _, name := range tableFilter.Except { - if (schema == "main" && !strings.Contains(name, ".")) || strings.HasPrefix(name, schema+".") { - exclude = append(exclude, name) + if len(include) > 0 { + subqueries = append(subqueries, fmt.Sprintf("name in (%s)", strmangle.Placeholders(true, len(include), 1, 1))) + for _, w := range include { + args = append(args, w) + } } - } - - if len(include) > 0 { - query += fmt.Sprintf(" and name in (%s)", strmangle.Placeholders(true, len(include), 1, 1)) - for _, w := range include { - args = append(args, w) + if len(regexPatterns) > 0 { + subqueries = append(subqueries, fmt.Sprintf("name regexp (%s)", strmangle.Placeholders(true, 1, len(args)+1, 1))) + args = append(args, strings.Join(regexPatterns, "|")) + } + if len(subqueries) > 0 { + query += fmt.Sprintf(" and (%s)", strings.Join(subqueries, " or ")) } } - if len(exclude) > 0 { - query += fmt.Sprintf(" and name not in (%s)", strmangle.Placeholders(true, len(exclude), 1+len(include), 1)) - for _, w := range exclude { - args = append(args, w) + if len(tableFilter.Except) > 0 { + var subqueries []string + stringPatterns, regexPatterns := tableFilter.ClassifyPatterns(tableFilter.Except) + exclude := make([]string, 0, len(tableFilter.Except)) + for _, name := range stringPatterns { + if (schema == "main" && !strings.Contains(name, ".")) || strings.HasPrefix(name, schema+".") { + exclude = append(exclude, strings.TrimPrefix(name, schema+".")) + } + } + if len(exclude) > 0 { + subqueries = append(subqueries, fmt.Sprintf("name not in (%s)", strmangle.Placeholders(true, len(exclude), 1+len(args), 1))) + for _, w := range exclude { + args = append(args, w) + } + } + if len(regexPatterns) > 0 { + subqueries = append(subqueries, fmt.Sprintf("name not regexp (%s)", strmangle.Placeholders(true, 1, len(args)+1, 1))) + args = append(args, strings.Join(regexPatterns, "|")) + } + if len(subqueries) > 0 { + query += fmt.Sprintf(" and (%s)", strings.Join(subqueries, " and ")) } } @@ -165,9 +185,10 @@ func (d *driver) tables(ctx context.Context) ([]drivers.Table, error) { return nil, err } + colFilter := drivers.ParseColumnFilter(mainTables, d.config.Only, d.config.Except) allTables := make([]drivers.Table, len(mainTables)) for i, name := range mainTables { - allTables[i], err = d.getTable(ctx, "main", name) + allTables[i], err = d.getTable(ctx, "main", name, colFilter) if err != nil { return nil, err } @@ -179,9 +200,9 @@ func (d *driver) tables(ctx context.Context) ([]drivers.Table, error) { if err != nil { return nil, err } - + colFilter = drivers.ParseColumnFilter(tables, d.config.Only, d.config.Except) for _, name := range tables { - table, err := d.getTable(ctx, schema, name) + table, err := d.getTable(ctx, schema, name, colFilter) if err != nil { return nil, err } @@ -192,7 +213,7 @@ func (d *driver) tables(ctx context.Context) ([]drivers.Table, error) { return allTables, nil } -func (d driver) getTable(ctx context.Context, schema, name string) (drivers.Table, error) { +func (d driver) getTable(ctx context.Context, schema, name string, colFilter drivers.ColumnFilter) (drivers.Table, error) { var err error table := drivers.Table{ @@ -206,7 +227,7 @@ func (d driver) getTable(ctx context.Context, schema, name string) (drivers.Tabl return table, err } - table.Columns, err = d.columns(ctx, schema, name, tinfo) + table.Columns, err = d.columns(ctx, schema, name, tinfo, colFilter) if err != nil { return table, err } @@ -234,7 +255,7 @@ func (d driver) getTable(ctx context.Context, schema, name string) (drivers.Tabl // from the database. It retrieves the column names // and column types and returns those as a []Column after TranslateColumnType() // converts the SQL types to Go types, for example: "varchar" to "string" -func (d driver) columns(ctx context.Context, schema, tableName string, tinfo []info) ([]drivers.Column, error) { +func (d driver) columns(ctx context.Context, schema, tableName string, tinfo []info, colFilter drivers.ColumnFilter) ([]drivers.Column, error) { var columns []drivers.Column //nolint:prealloc //nolint:gosec @@ -255,7 +276,18 @@ func (d driver) columns(ctx context.Context, schema, tableName string, tinfo []i } } + filter := colFilter[tableName] + excludedColumns := make(map[string]struct{}, len(filter.Except)) + if len(filter.Except) > 0 { + for _, w := range filter.Except { + excludedColumns[w] = struct{}{} + } + } + for _, colInfo := range tinfo { + if _, ok := excludedColumns[colInfo.Name]; ok { + continue + } column := drivers.Column{ Name: colInfo.Name, DBType: strings.ToUpper(colInfo.Type), diff --git a/gen/bobgen-sqlite/driver/sqlite.golden.json b/gen/bobgen-sqlite/driver/sqlite.golden.json index e4bb7f9d..12dff48c 100644 --- a/gen/bobgen-sqlite/driver/sqlite.golden.json +++ b/gen/bobgen-sqlite/driver/sqlite.golden.json @@ -156,6 +156,206 @@ "uniques": [] } }, + { + "key": "bar_baz", + "schema": "", + "name": "bar_baz", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_main_bar_baz", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "bar_qux", + "schema": "", + "name": "bar_qux", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_main_bar_qux", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "foo_bar", + "schema": "", + "name": "foo_bar", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_main_foo_bar", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "foo_baz", + "schema": "", + "name": "foo_baz", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_main_foo_baz", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "foo_qux", + "schema": "", + "name": "foo_qux", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_main_foo_qux", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, { "key": "has_generated_columns", "schema": "", @@ -387,6 +587,206 @@ "uniques": [] } }, + { + "key": "one.bar_baz", + "schema": "one", + "name": "bar_baz", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_one_bar_baz", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.bar_qux", + "schema": "one", + "name": "bar_qux", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_one_bar_qux", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.foo_bar", + "schema": "one", + "name": "foo_bar", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_one_foo_bar", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.foo_baz", + "schema": "one", + "name": "foo_baz", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_one_foo_baz", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, + { + "key": "one.foo_qux", + "schema": "one", + "name": "foo_qux", + "columns": [ + { + "name": "id", + "db_type": "INTEGER", + "default": "auto_increment", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "int32" + }, + { + "name": "secret_col", + "db_type": "TEXT", + "default": "", + "comment": "", + "nullable": false, + "generated": false, + "autoincr": false, + "domain_name": "", + "type": "string" + } + ], + "indexes": [], + "constraints": { + "primary": { + "name": "pk_one_foo_qux", + "columns": [ + "id" + ] + }, + "foreign": [], + "uniques": [] + } + }, { "key": "one.sponsors", "schema": "one", diff --git a/gen/bobgen-sqlite/driver/sqlite_test.go b/gen/bobgen-sqlite/driver/sqlite_test.go index 62ba2f6f..41e85c5e 100644 --- a/gen/bobgen-sqlite/driver/sqlite_test.go +++ b/gen/bobgen-sqlite/driver/sqlite_test.go @@ -3,12 +3,14 @@ package driver import ( "context" "database/sql" + sqlDriver "database/sql/driver" _ "embed" "errors" "flag" "fmt" "io/fs" "os" + "regexp" "testing" "github.com/stephenafamo/bob/gen" @@ -16,7 +18,7 @@ import ( "github.com/stephenafamo/bob/gen/drivers" testfiles "github.com/stephenafamo/bob/test/files" testutils "github.com/stephenafamo/bob/test/utils" - _ "modernc.org/sqlite" + "modernc.org/sqlite" ) func cleanup(t *testing.T, config Config) { @@ -57,6 +59,10 @@ func TestAssemble(t *testing.T) { } defer db.Close() + if err = registerRegexpFunction(); err != nil { + t.Fatal(err) + } + for schema, conn := range config.Attach { _, err = db.ExecContext(ctx, fmt.Sprintf("attach database '%s' as %q", conn, schema)) if err != nil { @@ -80,6 +86,93 @@ func TestAssemble(t *testing.T) { config: config, goldenJson: "sqlite.golden.json", }, + { + name: "include tables", + config: Config{ + DSN: config.DSN, + Attach: config.Attach, + Only: map[string][]string{ + "foo_bar": nil, + "foo_baz": nil, + "one.foo_bar": nil, + "one.foo_baz": nil, + }, + }, + goldenJson: "include-tables.golden.json", + }, + { + name: "exclude tables", + config: Config{ + DSN: config.DSN, + Attach: config.Attach, + Except: map[string][]string{ + "foo_bar": nil, + "foo_baz": nil, + "one.foo_bar": nil, + "one.foo_baz": nil, + "*": {"secret_col"}, + }, + }, + goldenJson: "exclude-tables.golden.json", + }, + { + name: "include + exclude tables", + config: Config{ + DSN: config.DSN, + Attach: config.Attach, + Only: map[string][]string{ + "foo_bar": nil, + "foo_baz": nil, + "one.foo_bar": nil, + "one.foo_baz": nil, + }, + Except: map[string][]string{ + "foo_bar": nil, + "bar_baz": nil, + "one.foo_bar": nil, + "one.bar_baz": nil, + }, + }, + goldenJson: "include-exclude-tables.golden.json", + }, + { + name: "include + exclude tables regex", + config: Config{ + DSN: config.DSN, + Attach: config.Attach, + Only: map[string][]string{ + "/^foo/": nil, + "/^bar/": nil, + }, + Except: map[string][]string{ + "/bar$/": nil, + "/baz$/": nil, + }, + }, + goldenJson: "include-exclude-tables-regex.golden.json", + }, + { + name: "include + exclude tables mixed", + config: Config{ + DSN: config.DSN, + Attach: config.Attach, + Only: map[string][]string{ + "/^foo/": nil, + "bar_baz": nil, + "bar_qux": nil, + "one.bar_baz": nil, + "one.bar_qux": nil, + }, + Except: map[string][]string{ + "/bar$/": nil, + "foo_baz": nil, + "foo_qux": nil, + "one.foo_baz": nil, + "one.foo_qux": nil, + }, + }, + goldenJson: "include-exclude-tables-mixed.golden.json", + }, } for _, tt := range tests { @@ -110,3 +203,31 @@ func TestAssemble(t *testing.T) { }) } } + +func registerRegexpFunction() error { + return sqlite.RegisterScalarFunction("regexp", 2, func( + ctx *sqlite.FunctionContext, + args []sqlDriver.Value, + ) (sqlDriver.Value, error) { + if len(args) != 2 { + return nil, fmt.Errorf("expected 2 arguments, got %d", len(args)) + } + + re, ok := args[0].(string) + if !ok { + return nil, fmt.Errorf("expected string, got %T", args[0]) + } + + s, ok := args[1].(string) + if !ok { + return nil, fmt.Errorf("expected string, got %T", args[1]) + } + + match, err := regexp.MatchString(re, s) + if err != nil { + return nil, err + } + + return match, nil + }) +} diff --git a/gen/drivers/table.go b/gen/drivers/table.go index 01de59df..59427906 100644 --- a/gen/drivers/table.go +++ b/gen/drivers/table.go @@ -2,6 +2,7 @@ package drivers import ( "fmt" + "strings" ) // Table metadata from the database schema. @@ -75,6 +76,25 @@ type Filter struct { Except []string } +func (f Filter) ClassifyPatterns(patterns []string) ([]string, []string) { + const regexDelimiter = "/" + var stringPatterns, regexPatterns []string //nolint:prealloc + + for _, pattern := range patterns { + if f.isRegexPattern(pattern, regexDelimiter) { + regexPatterns = append(regexPatterns, strings.Trim(pattern, regexDelimiter)) + continue + } + stringPatterns = append(stringPatterns, pattern) + } + + return stringPatterns, regexPatterns +} + +func (f Filter) isRegexPattern(pattern, delimiter string) bool { + return strings.HasPrefix(pattern, delimiter) && strings.HasSuffix(pattern, delimiter) +} + type ColumnFilter map[string]Filter func ParseTableFilter(only, except map[string][]string) Filter { diff --git a/test/files/mysql/schema.sql b/test/files/mysql/schema.sql index 15f41c31..234b91b7 100644 --- a/test/files/mysql/schema.sql +++ b/test/files/mysql/schema.sql @@ -181,7 +181,7 @@ create table type_monsters ( generated_nnull text GENERATED ALWAYS AS (UPPER(text_nnull)) STORED NOT NULL, generated_null text GENERATED ALWAYS AS (UPPER(text_null)) STORED, - INDEX(int_one, int_two) + UNIQUE(int_one, int_two) ); create view user_videos as @@ -216,4 +216,25 @@ CREATE INDEX idx2 ON test_index_expressions ((col1 + col2), col3); CREATE INDEX idx3 ON test_index_expressions (col1, (col2 + col3)); CREATE INDEX idx4 ON test_index_expressions (col3); CREATE INDEX idx5 ON test_index_expressions (col1 DESC, col2 DESC); -CREATE INDEX idx6 ON test_index_expressions ((POW(col3, 2))); \ No newline at end of file +CREATE INDEX idx6 ON test_index_expressions ((POW(col3, 2))); + +CREATE TABLE foo_bar ( + id INT AUTO_INCREMENT PRIMARY KEY, + secret_col VARCHAR(255) NOT NULL +); +CREATE TABLE foo_baz ( + id INT AUTO_INCREMENT PRIMARY KEY, + secret_col VARCHAR(255) NOT NULL +); +CREATE TABLE foo_qux ( + id INT AUTO_INCREMENT PRIMARY KEY, + secret_col VARCHAR(255) NOT NULL +); +CREATE TABLE bar_baz ( + id INT AUTO_INCREMENT PRIMARY KEY, + secret_col VARCHAR(255) NOT NULL +); +CREATE TABLE bar_qux ( + id INT AUTO_INCREMENT PRIMARY KEY, + secret_col VARCHAR(255) NOT NULL +); diff --git a/test/files/psql/schema.sql b/test/files/psql/schema.sql index a9100627..dea5aec5 100644 --- a/test/files/psql/schema.sql +++ b/test/files/psql/schema.sql @@ -285,3 +285,28 @@ CREATE INDEX idx3 ON test_index_expressions (col1, (col2 + col3)); CREATE INDEX idx4 ON test_index_expressions (col3); CREATE INDEX idx5 ON test_index_expressions (col1 DESC, col2 DESC); CREATE INDEX idx6 ON test_index_expressions (POW(col3, 2)); + +CREATE TABLE foo_bar ( + id SERIAL PRIMARY KEY, + secret_col VARCHAR(255) NOT NULL +); + +CREATE TABLE foo_baz ( + id SERIAL PRIMARY KEY, + secret_col VARCHAR(255) NOT NULL +); + +CREATE TABLE foo_qux ( + id SERIAL PRIMARY KEY, + secret_col VARCHAR(255) NOT NULL +); + +CREATE TABLE bar_baz ( + id SERIAL PRIMARY KEY, + secret_col VARCHAR(255) NOT NULL +); + +CREATE TABLE bar_qux ( + id SERIAL PRIMARY KEY, + secret_col VARCHAR(255) NOT NULL +); diff --git a/test/files/sqlite/schema.sql b/test/files/sqlite/schema.sql index c300dcdd..84949fa4 100644 --- a/test/files/sqlite/schema.sql +++ b/test/files/sqlite/schema.sql @@ -263,3 +263,45 @@ CREATE INDEX idx3 ON test_index_expressions (col1, (col2 + col3)); CREATE INDEX idx4 ON test_index_expressions (col3); CREATE INDEX idx5 ON test_index_expressions (col1 DESC, col2 DESC); CREATE INDEX idx6 ON test_index_expressions (POW(col3, 2)); + +CREATE TABLE foo_bar ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + secret_col TEXT NOT NULL +); +CREATE TABLE foo_baz ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + secret_col TEXT NOT NULL +); +CREATE TABLE foo_qux ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + secret_col TEXT NOT NULL +); +CREATE TABLE bar_baz ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + secret_col TEXT NOT NULL +); +CREATE TABLE bar_qux ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + secret_col TEXT NOT NULL +); + +CREATE TABLE one.foo_bar ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + secret_col TEXT NOT NULL +); +CREATE TABLE one.foo_baz ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + secret_col TEXT NOT NULL +); +CREATE TABLE one.foo_qux ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + secret_col TEXT NOT NULL +); +CREATE TABLE one.bar_baz ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + secret_col TEXT NOT NULL +); +CREATE TABLE one.bar_qux ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + secret_col TEXT NOT NULL +); diff --git a/website/docs/code-generation/mysql.md b/website/docs/code-generation/mysql.md index 5c768de3..9034d85e 100644 --- a/website/docs/code-generation/mysql.md +++ b/website/docs/code-generation/mysql.md @@ -48,7 +48,31 @@ The values that exist for the drivers: | only | Only generate these | | | except | Skip generation for these | | -Example of Only/Except: +## Only/Except: + +The `only` and `except` configuration options can be used to specify which tables to include or exclude from code generation. You can either supply a list of table names or use regular expressions to match multiple tables. + +Consider the example below: + +```yaml +mysql: + only: + "/^foo/": + bar_baz: +``` + +This configuration only generates models for tables that start with `foo` and the table named `bar_baz`. + +Alternatively, the following example excludes these tables from code generation rather than including them: + +```yaml +mysql: + except: + "/^foo/": + bar_baz: +``` + +You may also exclude specific columns: ```yaml mysql: diff --git a/website/docs/code-generation/psql.md b/website/docs/code-generation/psql.md index cdf20923..1fc59da0 100644 --- a/website/docs/code-generation/psql.md +++ b/website/docs/code-generation/psql.md @@ -57,7 +57,31 @@ The values that exist for the drivers: | only | Only generate these | | | except | Skip generation for these | | -Example of Only/Except: +## Only/Except: + +The `only` and `except` configuration options can be used to specify which tables to include or exclude from code generation. You can either supply a list of table names or use regular expressions to match multiple tables. + +Consider the example below: + +```yaml +psql: + only: + "/^foo/": + bar_baz: +``` + +This configuration only generates models for tables that start with `foo` and the table named `bar_baz`. + +Alternatively, the following example excludes these tables from code generation rather than including them: + +```yaml +psql: + except: + "/^foo/": + bar_baz: +``` + +You may also exclude specific columns: ```yaml psql: diff --git a/website/docs/code-generation/sqlite.md b/website/docs/code-generation/sqlite.md index 7d2e6b0a..b3bb553c 100644 --- a/website/docs/code-generation/sqlite.md +++ b/website/docs/code-generation/sqlite.md @@ -39,17 +39,41 @@ SQLITE_DSN="file.db" The values that exist for the drivers: -| Name | Description | Default | -|---------------|-------------------------------------------|---------------------| -| dsn | Path to database | | -| attach | Schemas to attach and the path the the db | map[string]string{} | -| shared_schema | Schema to not include prefix in model | "main" | -| output | Folder for generated files | "models" | -| pkgname | Package name for generated code | "models" | -| only | Only generate these | | -| except | Skip generation for these | | - -Example of Only/Except: +| Name | Description | Default | +|---------------|------------------------------------------|---------------------| +| dsn | Path to database | | +| attach | Schemas to attach and the path to the db | map[string]string{} | +| shared_schema | Schema to not include prefix in model | "main" | +| output | Folder for generated files | "models" | +| pkgname | Package name for generated code | "models" | +| only | Only generate these | | +| except | Skip generation for these | | + +## Only/Except: + +The `only` and `except` configuration options can be used to specify which tables to include or exclude from code generation. You can either supply a list of table names or use regular expressions to match multiple tables. + +Consider the example below: + +```yaml +sqlite: + only: + "/^foo/": + bar_baz: +``` + +This configuration only generates models for tables that start with `foo` and the table named `bar_baz`. + +Alternatively, the following example excludes these tables from code generation rather than including them: + +```yaml +sqlite: + except: + "/^foo/": + bar_baz: +``` + +You may also exclude specific columns: ```yaml sqlite: