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

Cloned object make different SQL from the original. #51

Merged
merged 1 commit into from Nov 1, 2022

Conversation

ktat
Copy link
Contributor

@ktat ktat commented Oct 28, 2022

About SQL::Maker::select_query,
If it has scalar reference in select, SQL from cloned object is not same SQL with the one from an original object.

It causes that scalar reference's address is used as key of select_map.
So, in this fix, creating select_map from select_map_reverse in as_sql.
And if single scalar reference is given as $term in select, dereference it and set it to $col before $col ||= $term.

@ktat ktat changed the title Feature/fix cloned object Cloned object make different SQL from the original. Oct 28, 2022
@ktat
Copy link
Contributor Author

ktat commented Oct 28, 2022

The following is the result of t/select/03_clone.t with current version of SQL::Maker.

#          got: 'SELECT `a` AS `b`, `c`, d, count(*), sum(price)
# FROM `test`'
#     expected: 'SELECT `a` AS `b`, `c`, d, count(*) AS `cnt`, sum(price) AS `sum_price`
# FROM `test`'

@tokuhirom tokuhirom merged commit 41433f0 into tokuhirom:master Nov 1, 2022
tokuhirom added a commit that referenced this pull request Nov 1, 2022
Changelog diff is:

diff --git Changes Changes
index d6876e2..2d965d5 100644
--- Changes
+++ Changes
@@ -2,6 +2,12 @@ Revision history for Perl module SQL::Maker
 
 {{$NEXT}}
 
+1.22 2022-11-01T03:02:16Z
+
+    Cloned object make different SQL from the original. #51
+    #51
+    (ktat)
+
 1.21 2014-12-22T06:27:33Z
 
     Official support for directly passing a SQL::QueryMaker object as $where parameter #42
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.

None yet

2 participants