Skip to content

Primary key value in delete SQL is not integer (Oracle adapter) #520

openface opened this Issue Jul 17, 2012 · 2 comments

2 participants


I just noticed this behavior.

delete '/admin/rules/:id' do |id|
@rule = Rule.find(:id=>id)


Results in the following SQL:

I, [2012-07-17T10:34:21.410492 #9394] INFO -- : (0.083014s) SELECT * FROM (SELECT * FROM "NM_REQUESTS" WHERE ("ID" = 14)) "T1" WHERE (ROWNUM <= 1)
I, [2012-07-17T10:34:21.413837 #9394] INFO -- : (0.000003s) Transaction.begin
I, [2012-07-17T10:34:21.496202 #9394] INFO -- : (0.081909s) DELETE FROM "NM_REQUESTS" WHERE ("ID" = 14.0)
I, [2012-07-17T10:34:21.577711 #9394] INFO -- : (0.081328s) Transaction.commit

Specifically pointing out that the ID is 14.0. Seems this value should be cast to an Integer in the SQL query. I have not looked at the source to confirm solution, but thought I'd mention it here as a minor issue.


Does this cause any problems? The underlying issue is that Oracle does not have an integer type, only a number type. Automatically casting to integer would break things if the primary key was a varchar field, for example. You could probably use the typecast_on_load plugin to automatically cast the primary key to integer (assuming Rule.db_schema[:id][:type] is :integer) if you really want it casted to an integer, or do:

class Rule
  def id
    if v = super

No problems caused by this -- this was mainly informational to make you aware.

@openface openface closed this Jul 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.