fusion_tables icon indicating copy to clipboard operation
fusion_tables copied to clipboard

Need a OO way to update and delete using a WHERE instead of a rowid

Open colindean opened this issue 13 years ago • 4 comments

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.

colindean avatar Nov 10 '11 22:11 colindean

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?

colindean avatar Nov 10 '11 22:11 colindean

Get the rowid by simply selecting rowid in the select.

colindean avatar Nov 10 '11 22:11 colindean

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

tokumine avatar Nov 11 '11 16:11 tokumine

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:

  1. Expect the user to use .each on the array and execute multiple .update calls
  2. 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?

colindean avatar Nov 14 '11 14:11 colindean