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

Error upon creating a large FLOAT from schema.rb, converts to NUMBER with max length of 38 #564

Closed
lustremedia opened this issue Mar 19, 2015 · 6 comments

Comments

@lustremedia
Copy link

ruby 2.0.0p353
Rails 4.1

gem "activerecord-oracle_enhanced-adapter", "~> 1.5.0"

Error message: (sorry it is in German)

ActiveRecord::StatementInvalid: OCIError: ORA-01727: Numerische Stellenangabe liegt außerhalb des gültigen Bereiches (1 - 38): CREATE TABLE "EUROFXREF" ("CURRENCY" NUMBER(38) NOT NULL PRIMARY KEY, "RATE" NUMBER(126), "UPDATED" DATE) 
stmt.c:230:in oci8lib_200.so

Fails upon this create statement

create_table "eufx", primary_key: "currency", force: true do |t|
    t.float    "rate",    limit: 126
    t.datetime "updated"
  end
@yahonda
Copy link
Collaborator

yahonda commented May 12, 2015

As of right now Rails :float datatype is mapped to Oracle NUMBER type, then you cannot take limit: 126

Please give it a try updating Gemfile as follows.

gem 'activerecord-oracle_enhanced-adapter', github: 'yahonda/oracle-enhanced', branch: 'issue564'

This branch changes to map :float type to Oracle BINARY_FLOAT.
Since we need to keep the compatibility within Oracle enhanced adapter 1.5.x it will not be changed to version 1.5.x. But wanted to know if it works.

@lustremedia
Copy link
Author

Using that I will get no schema error however I get following:

rake aborted!
NoMethodError: undefined method type_cast_for_database' for nil:NilClass`

@lustremedia
Copy link
Author

With branch 42 I get following error message:

ActiveRecord::StatementInvalid: OCIError: ORA-00907: Rechte Klammer fehlt * : CREATE TABLE "EUROFXREF" ("CURRENCY" NUMBER(38) NOT NULL PRIMARY KEY, "RATE" BINARY_FLOAT(38), "UPDATED" DATE) stmt.c:250:in oci8lib_200.so

Rechte Klammer fehlt * => right bracket missing

@yahonda
Copy link
Collaborator

yahonda commented Jul 21, 2015

Let me summarize Rails :float support:

  • Rails 4.1 and Oracle enhanced adapter 1.5.5

Rails :float datatype can be mapped to Oracle NUMBER datatype by setting self.number_datatype_coercion = :float.
Here, Oracle data type is NUMBER, then precision of NUMBER(p) p cannot be larger than 38.

  • Rails 4.2 and Oracle enhanced adapter 1.6

Rails :float datatype is mapped to Oracle BINARY_FLOAT datatype by default.
self.number_datatype_coercion = :float has been removed in Oracle enhanced adapter 1.6.

Here you cannot specify precisions for binary_float datatype since Oracle BINARY_FLOAT does not support
to set precision. You will get (

ERROR at line 1:
ORA-00907: missing right parenthesis
  • Bottomline
    I can suggest you to upgrade to Rails 4.2 and Remove limit: 126 from your migration.

@lustremedia
Copy link
Author

Ok I am in the middle of the upgrade to 4.2. I will let you know if your suggestion worked. Cheers

@yahonda
Copy link
Collaborator

yahonda commented Oct 12, 2015

Closing this due to no feedback available yet. Please reopen if it still reproduce.

@yahonda yahonda closed this as completed Oct 12, 2015
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