[This post is an archive from the old SQL Yoga forums]
Can someone confirm that trying to set some condition for a query like:
put ":1 is in" && primaryKeyForTable(pTable) into theFilterA["conditions"]
put sqlyoga_escapeString("sqlite",tKey) into theFilterA["condition bindings"][1]
sqlrecord_find pTable, theFilterA, tLocalRecordA
Where the primary key is a string value. This generates a query like:
sqlyoga_executesql_err,Database Error: SQL error or missing database
Query: SELECT templates.title AS "templates.title", templates.type AS "templates.type", templates.content AS "templates.content", templates.datemodified AS "templates.datemodified" FROM templates WHERE MP4 Video IN (title)
As we can see the value MP4 Video should be quoted, if I manually put quotes around it, then when the query is generated, the value is double quoted?!
I am using SQL Yoga 1.0 build 15
[bug] failing to quote primary key if not a number
Moderators: FourthWorld, heatherlaine, Klaus, robinmiller, trevordevore
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
- Contact:
[bug] failing to quote primary key if not a number
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
- Contact:
Re: [bug] failing to quote primary key if not a number
When working with "conditions" (the WHERE clause) and bindings SQL Yoga will escape special characters in the value you insert but will not add the single quotes around it. This is because certain conditions don't work if single quotes are around them (i.e. WHERE ID IN (:1) ).
You can read more about the "conditions" property on the sqlquery_set page:
http://www.bluemangolearning.com/revolu ... ry_set.htm
By the way, if you define a table object for your table then "primary key" becomes an accessible property.
Code: Select all
put "':1' is in" && primaryKeyForTable(pTable) into theFilterA["conditions"]
put tKey into theFilterA["condition bindings"][1]
sqlrecord_find pTable, theFilterA, tLocalRecordA
http://www.bluemangolearning.com/revolu ... ry_set.htm
By the way, if you define a table object for your table then "primary key" becomes an accessible property.
Code: Select all
put tableobj_get(pTable, "primary key") into thePrimaryKey
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder