Skip to content

Fix clone of embedded literal sql - #119

Merged
servant-42 merged 1 commit into
2.xfrom
clone-w-sql
May 15, 2020
Merged

Fix clone of embedded literal sql#119
servant-42 merged 1 commit into
2.xfrom
clone-w-sql

Conversation

@servant-42

@servant-42 servant-42 commented May 15, 2020

Copy link
Copy Markdown
Collaborator

This fixes #118, with a couple of tests to protect against regressions.

The docs state that sql() should be used:

somewhere that a value is expected (the right-hand side of WHERE criteria, or insert()/update() values)

and in these situations, clone() was working correctly because it doesn't clone values (which are typically immutable, though I suppose it's technically possible for someone to mutate a sql() literal).

But right after that, the docs give an example where sql() is used in a higher-level context -- not just as a value, but as the entire WHERE expression. It is in these cases that it was throwing the error, and this is what was fixed in this pull request.

I should probably update the docs to explicitly allow sql() in more contexts and should think a little harder about whether we really need/want that functionality in the big 3.x refactor (which may never happen, at this rate).

@servant-42
servant-42 merged commit aebaf79 into 2.x May 15, 2020
@servant-42
servant-42 deleted the clone-w-sql branch May 15, 2020 19:40
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.

1 participant