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
sql_type check in have_db_column #1432
Comments
On the surface it seems like a small change, but I'm curious, are you worried that Rails will do the wrong thing here and not assign the correct SQL type? I have been increasingly questioning the value of |
I suppose it is more testing configuration than logic when you think hard about it, but given that Rails models are so inherently tied to the database it seems sensible to me to have a buffer between changes. When you have migrations being picked up from so many different engines like we do it makes sense to have the engine that requires the presence of a particular field also validate that the field exists when the tests across all engines are run (makes sure another engine doesn't have conflicting migrations etc). Especially when those migrations use actual sql types rather than the rails built-in It's also pretty good documentation for the model itself that saves having to dive through I guess it may make less sense in the typical rails app setup rather than an application split into 20 or so engines? It's up to you, I wrote a custom matcher for our stuff that did this - I just thought it'd be nice to upstream it if other people would also like to validate db schema in the same way. |
Ah, engines, okay. I can see how that could end up creating potentially confusing situations. And my second question was going to be about whether you are using Okay, I can see the use case behind this. Send a PR over and we will be happy to merge this. :) |
This commit intends to implement the `of_sql_type` qualifier on the `have_db_column` matcher. The implementation is quite simple and is following the pattern of the `HaveDbColumnMatcher` class. This commit closes this issue thoughtbot#1432
This commit intends to implement the `of_sql_type` qualifier on the `have_db_column` matcher. The implementation is quite simple and is following the pattern of the `HaveDbColumnMatcher` class. This commit closes this issue thoughtbot#1432
Would you guys be open to a PR to add a method into the
have_db_column
chain that checks thesql_type
of the column? Currently there is only one fortype
which I think is insufficient when dealing with certain column types.For instance, say you are storing guids in a
char(36)
column, rails will interpret that as:string
. In this case it is quite important that the column is actually a mysqlchar(36)
instead.I was thinking to just add an additional method into
have_db_column
so you can specify something like:I'm happy to do the PR if you guys are open to it.
The text was updated successfully, but these errors were encountered: