fusion_tables
fusion_tables copied to clipboard
Need a OO way to update and delete using a WHERE instead of a rowid
It seems as if there is no way to get the rowid from using the Table#select method.
Assuming the table has a unique column, it could be used in a where clause in place of a rowid.
Obviously, the workaround for this is to just execute the SQL directly.
Actually, when I try to execute the update with a where clause, I get an error:
Parse error near 'vse_key' (line 1, position 33). Expecting ROWID instead.
How can I get the rowid?
Get the rowid by simply selecting rowid
in the select.
Hi Colin!
I don't really have time to add new features to the oo side of things (I tend to just use the SQL interface). If you submit a patch and tests I'll be happy to add you to the contributors and bump the gem!
Cheers,
Simon
On 10 Nov 2011, at 22:32, Colin [email protected] wrote:
It seems as if there is no way to get the rowid from using the Table#select method.
Assuming the table has a unique column, it could be used in a where clause in place of a rowid.
Reply to this email directly or view it on GitHub: https://github.com/tokumine/fusion_tables/issues/13
Alrighty!
I think I'll add a Table#rowids(where_clause=nil) method which will execute SELECT rowid FROM #{table_id}
and add the where clause if specified. It will return an array of rowids.
Then, there are two options:
- Expect the user to use .each on the array and execute multiple .update calls
- Modify the Table#update method to accept an array for the rowid parameter, and the method will do the multiple calls itself or append
WHERE rowid in (#{rowid.join[',']})
if Fusion Tables supports such.
Thoughts?