Skip to content
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

Full stack mysql test environment #321

Merged
merged 8 commits into from
Nov 28, 2020
Merged

Conversation

andrewhj
Copy link
Contributor

@andrewhj andrewhj commented Nov 24, 2020

Fixes #69

Created mysql environment heavily insipred (copy/pasted) by the postgres
module.

MysqlModule.scala: performs the conversion of zio-sql functions into
mysql compatible sql. Currently a copy/paste & rename of the postgres
module.

FunctionDefSpec.scala: module for testing mysql functions (lower, sin,
etc.)

MysqlModuleTest.scala: runs mysql tests, table selects, limits, offset,
etc.

MysqlRunnableSpec.scala:

ShopSchema.scala: defines schema (loaded in test container definition)

added mysql test container dependencies
TestContainers.scala: created container definition as part of the mysql
project.  We may want to move and merge this file with postgresql
version in a common location.

shop_schema.sql: called by TestContainer to bootstrap test data in
docker instance.
@andrewhj andrewhj force-pushed the full-stack-mysql branch 2 times, most recently from fd48d57 to af12376 Compare November 24, 2020 08:12
@robmwalsh robmwalsh self-requested a review November 25, 2020 03:00
Copy link
Contributor

@robmwalsh robmwalsh left a comment

Choose a reason for hiding this comment

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

Awesome work thanks @andrewhj! Noting my comments here #69 (comment) can you please remove the "simple" table and use one of the existing tables instead? Other than that I think this is good to merge!

mysql/src/test/resources/shop_schema.sql Outdated Show resolved Hide resolved
mysql/src/test/resources/shop_schema.sql Outdated Show resolved Hide resolved
mysql/src/test/scala/zio/sql/mysql/MysqlModuleTest.scala Outdated Show resolved Hide resolved
mysql/src/test/scala/zio/sql/mysql/ShopSchema.scala Outdated Show resolved Hide resolved
@andrewhj
Copy link
Contributor Author

yes I can do that. I added the simple table because the task started expanding further away from the original intent. Mysql either doesn't support (or supports differently) the concept of uuid for example so I changed the id columns to varchar. Is that ok? Going in with that in mind, I'll work on matching up the rows and tests to postgres data example.

@robmwalsh
Copy link
Contributor

Varchar is horribly inefficient for storing UUIDs. Perhaps changing them to Ints for now would be better? A bit of a pain on the test data but find replace on the primary column wouldn't be amazingly terrible. I think down the track we should probably have something more like binary(16) as described here https://mysqlserverteam.com/storing-uuid-values-in-mysql-tables/ and take care of the conversion. That would be transparent when using zio-sql for queries but makes hand writing queries much harder. Might be a good justification for allowing users to define how they want to store types.

Created mysql environment heavily insipred (copy/pasted) by the postgres
module.

MysqlModule.scala: performs the conversion of zio-sql functions into
mysql compatible sql.  Currently a copy/paste & rename of the postgres
module.

FunctionDefSpec.scala: module for testing mysql functions (lower, sin,
etc.)

MysqlModuleTest.scala: runs mysql tests, table selects, limits, offset,
etc.

MysqlRunnableSpec.scala:

ShopSchema.scala: defines schema (loaded in test container definition)
@andrewhj
Copy link
Contributor Author

well, that was a mistake. I'll work through the merge issues. I had tests working with varchar storing UUID. I think that is a nice spot despite the mentioned inefficiency of varchar. The tests remain closer to postgresql examples. If we really want to convert to using ints instead of varchar/uuid, I can work on that next. It requires changes to ShopSchema, shop_schema.sql, and the MysqlRunnableSpec.

GroupByHavingSpec: reformatted in order to fix sbt check failure
MysqlModule: added stubs for new renderUpdate/renderDelete methods that
have been added to Jdbc.

MysqlRunnableSpec: added DeleteExecutor to the jdbcTestEnvironment
@jczuchnowski jczuchnowski merged commit b60d869 into zio:master Nov 28, 2020
@andrewhj andrewhj deleted the full-stack-mysql branch December 5, 2020 08:43
amrkamel pushed a commit to amrkamel/zio-sql that referenced this pull request May 26, 2022
Full stack mysql test environment
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 full-stack test for MySQL
3 participants