Skip to content

mysql type overrides #281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 28, 2020
Merged

mysql type overrides #281

merged 7 commits into from
Jan 28, 2020

Conversation

cmoog
Copy link
Contributor

@cmoog cmoog commented Jan 19, 2020

Fixes #273 .

This implements package-level and global type overrides for mysql usage.

Implementation notes

I adjusted a few data structures to ease the passing of package settings and database schema throughout the parsing and generation process.
The primary new structures are shown below.

type PackageGenerator struct {
	*Schema
	dinosql.CombinedSettings
	packageName string
}

type Result struct {
	PackageGenerator
	Queries []*Query
}

By separating the schema and package settings from the constructed queries, we're able to keep many of the parsing functions more functionally pure.

@cmoog cmoog requested a review from kyleconroy January 22, 2020 04:40
Copy link
Collaborator

@kyleconroy kyleconroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking very close to shipping. I left a few comments that should be easy to address. After this is merged, I'll work on porting most of the MySQL tests to the new end-to-end framework.

@@ -26,6 +28,7 @@ type Author struct {

type Book struct {
BookID int
BookUUID uuid.UUID
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The booktest examples is taken from xo/xo. The PostgreSQL and MySQL versions should be the same as that project.

Can you back out your multiple changes to this file and add tests for overrides in the internal/endtoend/testdata directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kyleconroy How do you think we should organize the new testdata directory with multiple database engines?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Individual tests should be in a subdirectory of testdata. Unless we're testing multi-engine configuration, we probably want to keep tests for each engine separate.

@kyleconroy kyleconroy merged commit efcc4fe into sqlc-dev:master Jan 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add support for type overrides when using mysql
2 participants