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

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

Open
colindean opened this issue Nov 10, 2011 · 4 comments
Open

Comments

@colindean
Copy link

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
Copy link
Author

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
Copy link
Author

Get the rowid by simply selecting rowid in the select.

@tokumine
Copy link
Owner

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:
#13

@colindean
Copy link
Author

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?

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