Repository navigation
Conversation
8000
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request updates GoFrame’s gdb and gf gen dao tooling to support PostgreSQL schema selection (schema-as-namespace) without conflating it with the database name, enabling correct multi-schema workflows for pgsql.
Changes:
- Add
--schemasupport togf gen dao(plus config metadata + tests) and apply the selected schema viadb.Schema(...)during generation. - Refine
gdb.Coreschema handling so PostgreSQL usesConfigNode.Namespace(schema) while preservingConfigNode.Name(database). - Update the PostgreSQL driver and unit tests to treat
publicas the default schema and useGetSchema()consistently.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| database/gdb/gdb.go | Adds pgsql driver type constant and applies schema to config nodes via a driver-aware helper. |
| database/gdb/gdb_core_config.go | Updates GetSchema() so PostgreSQL schema comes from Namespace rather than Name. |
| database/gdb/gdb_z_unit_schema_test.go | Adds unit test verifying driver-specific schema assignment behavior (pgsql vs mysql). |
| contrib/drivers/pgsql/pgsql_z_unit_init_test.go | Adjusts pgsql test initialization to separate database name vs schema and default to public. |
| contrib/drivers/pgsql/pgsql_z_unit_filter_test.go | Updates schema arguments in pgsql tests to use the shared SchemaName. |
| contrib/drivers/pgsql/pgsql_z_unit_feature_metadata_test.go | Updates schema-related test comment to reflect public default. |
| contrib/drivers/pgsql/pgsql_tables.go | Uses GetSchema() for table discovery and reorders link retrieval accordingly. |
| cmd/gf/internal/cmd/gendao/gendao.go | Adds Schema to input and applies it to the DB instance before table discovery/generation. |
| cmd/gf/internal/cmd/gendao/gendao_test.go | Adds unit test verifying Schema is exposed via struct tags/metadata. |
| cmd/gf/internal/cmd/gendao/gendao_tag.go | Updates CLI help/config examples and adds the schema brief/metadata entry. |
| cmd/gf/internal/cmd/cmd_z_unit_gen_dao_test.go | Adds integration-style unit test generating DAOs from a dynamically created PostgreSQL schema. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
59
to
62
| schemaTemplate := "SELECT 'CREATE DATABASE %s' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = '%s')" | ||
| if _, err := db.Exec(ctx, fmt.Sprintf(schemaTemplate, SchemaName, SchemaName)); err != nil { | ||
| if _, err := db.Exec(ctx, fmt.Sprintf(schemaTemplate, DatabaseName, DatabaseName)); err != nil { | ||
| gtest.Error(err) | ||
| } |
Member
|
This looks like useful PostgreSQL schema support, and the tests/help text around
I have not added the |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4127
fix(database/gdb): implement PostgreSQL schema handling
fix(gendao): support PostgreSQL schema generation
This pull request introduces support for PostgreSQL schema selection in the
gen daocommand and improves schema handling across the codebase, especially for PostgreSQL. It adds a new--schemaoption, updates documentation and test coverage, and refines internal logic to correctly handle schema configuration for different drivers.PostgreSQL Schema Support in
gen dao:Schemafield toCGenDaoInput, exposed as the--schemacommand-line option and in config metadata, allowing users to specify which PostgreSQL schema to use when generating DAOs. [1] [2] [3]doGenDaoForArrayfunction to switch the database context to the selected schema if specified.Test_Gen_Dao_PostgreSQLSchema) to verify DAO generation from a specific PostgreSQL schema.--schemaoption with PostgreSQL. [1] [2]Internal Schema Handling Improvements:
gdb.Coreto use a new helper,setSchemaToConfigNode, which ensures PostgreSQL schema selection uses theNamespacefield and does not overwrite the database name. [1] [2] [3] [4]PostgreSQL Driver and Test Adjustments:
GetSchema()instead ofNamespacedirectly.publicas the default PostgreSQL schema, improving test clarity and correctness. [1] [2] [3] [4] [5]These changes ensure that schema selection is explicit, consistent, and driver-appropriate, especially for PostgreSQL users working with multiple schemas.