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

QuickQB.update - invalid argument type assumption leading to expression exception #246

Open
davidAtInleague opened this issue Jan 26, 2024 · 1 comment

Comments

@davidAtInleague
Copy link
Contributor

quick 7.3.1

quick/models/QuickQb.cfc

Hit a case where Quick tries to treat a string as a struct, e.g. in the following, if values is something like {someColumn: "someValue"}

	public any function update(
		struct values  = {},
		struct options = {},
 		boolean toSql  = false
 	) {
 		for ( var key in arguments.values ) {
 			if ( structKeyExists( arguments.values[ key ], "isQuickBuilder" ) ) {
 				arguments.values[ key ] = arguments.values[ key ].getQb();
 			}

The structKeyExists becomes structKeyExists( "someValue", "isQuickBuilder" ) which fails with "cannot convert string to struct".

Our current workaround is:

diff --git a/modules/quick/models/QuickQB.cfc b/modules/quick/models/QuickQB.cfc
index 457378a20..2567f341d 100755
--- a/modules/quick/models/QuickQB.cfc
+++ b/modules/quick/models/QuickQB.cfc
@@ -305,6 +305,9 @@ component
 		boolean toSql  = false
 	) {
 		for ( var key in arguments.values ) {
+			if ( isNull( arguments.values[ key ] ) || isSimpleValue( arguments.values[ key ] ) ) {
+				continue;
+			}
 			if ( structKeyExists( arguments.values[ key ], "isQuickBuilder" ) ) {
 				arguments.values[ key ] = arguments.values[ key ].getQb();
 			}
@elpete
Copy link
Collaborator

elpete commented May 31, 2024

Do you have a way to reproduce this? All the code in Quick that calls .update first generates query param structs using the generateQueryParamStruct method on QuickBuilder.

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

No branches or pull requests

2 participants