-
Notifications
You must be signed in to change notification settings - Fork 51
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
Improve checking of InnerJoin clause ordering #59
Comments
I assume you're talking about run time checks. Then the only reason I'd be opposed to them was if they had a perceivable performance hit, which I don't expect. Perhaps it may be possible fixing this at the type level using a type level stack. I may oppose a type level check if it turns out to be too complicated. Other than these, I can't think of any other caveat, so go ahead! =) |
Well personally, I'd much prefer a compile time check but I'd settle for run-time. Might be worth doing a run-time check first and then trying to promote it to compile time. |
I'd too prefer a compile time check, I'm just careful not to turn esqueleto into a bigger monster than it already is =). It depends on how complex the solution needs to be. |
@erikd Can you give an example of an expression that Sqlite accepts and Postgres rejects? |
Ok, simple program (which from a strict reading of the documentation has a bug) here:
which can be run with Sqlite using:
and with Postgresql using:
Sqlite accepts the generated query, but Postgresql does not. The bug is that the
which is then accepted by both Sqlite and Postgresql. It would be nice if this could be caught at compile time or better yet, corrected on-the-fly :-). |
Your first example is wrong, on clauses should be in reverse order. If that's not clear from the documentation, it should be improved. I would like to hear suggestions with respect to how this bug could have been caught by the type system :). |
@meteficha I did say " from a strict reading of the documentation has a bug" :-). The problem with this bug is that it only manifests at runtime. I am not a type level hacker so have no idea. |
The best practical solution I can think of is doing sanity checks at runtime. |
Sanity checks at runtime already exist. Its called Postgres :-) |
Fair enough =). |
It seems that Postgresql is much more sensitive to the ordering of the
on
clauses for theInnerJoin
or afrom
clause than Sqlite.If one writes a working query against Sqlite and then runs it against Postgresql it can give a rather ugly run-time failure. Unless one reads (again) the documentation for the
on
clause one is like to start digging into the Esqueleto code to figure out why.I propose that we add code to Esqueleto that enforces the
on
clause restrictions and print better error messages. I'm even willing to do the work :-)Is that a good idea?
The text was updated successfully, but these errors were encountered: