Comments (5)
You have not specified primary key for your table - by default it is "id" but in table creation you specified :id => false which means that "id" column is not created.
So in this case you need to use set_primary_key in your class definition to specify what is primary key (is it "identifier" or "serial"?). And you should also use set_sequence_name to specify which database sequence should be used to populate primary key value (if primary key is integer column).
Or do you want to access existing table and don't want to create new records there from ActiveRecord? In that case you don't need to create migration.
from oracle-enhanced.
This is an existing table. The schema is from the
rake db:schema:dump
command.
I included it in order to better illustrate what I was working with.
The primary key is not too much of an issue, and it doesn't seem to fix the problem.
The real problem, as I have since discovered, is that there are 'class' and 'type' columns in this table, which absolutely, categorically mess with ActiveRecord.
I can get around the 'type' issue by using the 'set_inheritance_column' attribute and setting my model as follows (and i set the primary key):
class Status < ActiveRecord::Base
set_table_name "reporter_status"
set_primary_key "serverserial"
set_inheritance_column :ruby_type
# getter for the "type" column
def status_type
self[:type]
end
# setter for the "type" column
def status_type=(s)
self[:type] = s
end
end
but I have yet to find something similar for the class attribute.
The ActiveRecord is usable, but only by not using the generated methods, as the following example shows:
>> s = Status.first
=> #<Status identifier: ".1.3.6.1.4.1.1899", serial: 674110192, node: "node", nodealias: ...
>> s.identifier
NoMethodError: undefined method `generated_methods' for 40000:Fixnum
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/attribute_methods.rb:243:in `method_missing'
from (irb):1
>> s[:class]
=> 40000
>> s[:identifier]
=> ".1.3.6.1.4.1.1899"
You can hack your views to use the 'instance[:parameter]' notation, but the UrlHelpers and thinks like that break.
I know that this is no longer an oracle_enhanced adapter issue, so if you can point me to another forum to post to, I will gladly proceed there.
In the meantime, I will head over to aptiva's ActiveRecord git repository and ask him.
Thanks.
from oracle-enhanced.
One workaround is that you could create database view on top of this table where you can rename table columns (type, class) which conflict with default Ruby methods. And then you can use set_table_name with this view in your class definition.
from oracle-enhanced.
I thought about that, and that was my next port of call.
Thanks very much.
from oracle-enhanced.
closing as we found some workaround
from oracle-enhanced.
Related Issues (20)
- ActiveRecord::ConnectionAdapters::OracleEnhanced::SchemaStatements#table_comment not working correctly in 6.x
- prefetch_primary_key? performance issues
- specify multiple parameters in config/database.yml(schema: parameter) HOT 2
- Upgrade from 5.2.8 to 6.1.4 - Error when database config attribute "username" leverages proxy auth format HOT 1
- JDBC_Connection.rb get_ruby_value_from_result_set doesn't handle BINARY_DOUBLE
- varchar to boolean mapping. HOT 1
- Support https://github.com/rails/rails/pull/44576
- Support https://github.com/rails/rails/pull/46273
- Can we expect a new release HOT 2
- emulate_booleans = false no longer being picked up in rails 7.0.4 HOT 4
- Issue using time_zone in database yml connecting to aws rds oracle databases HOT 3
- Question: Will you support JDBC Reactive Extensions? HOT 1
- Redmine HOT 1
- Support https://github.com/rails/rails/pull/44591 HOT 1
- db:schema:load fails with error `NoMethodError: undefined method 'to_sym' for {:type=>:string, :limit=>36}:Hash` HOT 5
- ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection::describe can fail for long table/view names
- Installation of >=v7.0.1 fails with JRuby HOT 5
- DB connection pool is not used when creating new connections
- Please privide Rails 7.1 compatibility HOT 11
- "Assign auto populated columns on Active Record object creation", breaks the returning of id on insert HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oracle-enhanced.