Skip to content

Kotlin mysql #775

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 4 commits into from
Nov 14, 2020
Merged

Kotlin mysql #775

merged 4 commits into from
Nov 14, 2020

Conversation

mightyguava
Copy link
Contributor

@mightyguava mightyguava commented Nov 9, 2020

Not much changed really.

  • Symlink the examples to Kotlin so that they are kept in sync. I'm not sure if this is for the best, since it does mean any changes to the Go examples would need updates to the Kotlin ones too.
  • Added support for :execresult
  • Add Kotlin MySQL examples and get tests working. (filtered commit)
  • Add support for all the new mysql types (filtered commit)

There's a lot of generated code changes and Kotlin test changes, so I've included (filtered commit) links that filter out .kt files for easier review. Also note this PR includes #774. I'll rebase when that's merged.

TODO for future PRs:

  • Iterate on the type mappings, maybe an option to use okio for ByteString.
  • More comprehensive test coverage
  • Split generated output to separate files per class to be more Java-ey

@@ -141,7 +141,9 @@ func Generate(e Env, dir string, stderr io.Writer) (map[string]string, error) {
if sql.Gen.Go != nil {
name = combo.Go.Package
} else if sql.Gen.Kotlin != nil {
parseOpts.UsePositionalParameters = true
if sql.Engine == config.EnginePostgreSQL {
parseOpts.UsePositionalParameters = true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This switch breaks MySQL since it's trying to replace non-existent $1 to ?. Not sure if some clever renaming would be useful here

@@ -46,6 +46,6 @@ jobs:
PG_PORT: ${{ job.services.postgres.ports['5432'] }}
MYSQL_DATABASE: mysql
MYSQL_HOST: localhost
MYSQL_PORT: ${{ job.services.mysql.ports['5432'] }}
MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This probably never worked? It probably interpolated into the empty string, and the tests used the default port which is 3306

@tirsen
Copy link

tirsen commented Nov 10, 2020

No example for a mysql List<String> query argument?

@mightyguava
Copy link
Contributor Author

No example for a mysql List<String> query argument?

Not supported. sqlc doesn't currently have support for variable length arguments AFAIK and MySQL doesn't have support for passing an array as a single parameter. It would be nice to find a solution for this.

@mightyguava
Copy link
Contributor Author

Looks like passing slices is being discussed in #695

@mightyguava mightyguava force-pushed the kotlin-mysql branch 2 times, most recently from d856776 to d7c05e9 Compare November 13, 2020 17:36
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.

@mightyguava I merged in your PR that removed the runtime, which has caused merge conflicts. Can you update this PR with the latest master?

Not much changed really.

* Added support for `:execresult`
* Add Kotlin MySQL examples and get tests working.
and adds MySQL tests for all existing examples
@mightyguava
Copy link
Contributor Author

I did a rebase and git auto-resolved the conflicts.

@kyleconroy kyleconroy merged commit f9fd0b6 into sqlc-dev:master Nov 14, 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.

3 participants