Eden Brandeis
2006-Jan-05 22:58 UTC
[Rails] Repost - Do dynamic finders work with legacy schemas?
Hello everyone, I have another question related to a legacy schema I am working with. Do dynamic finders work with legacy schemas in general? The schema I am working with uses hungarian prefixes for column names. For example fOpen is 0 if a bug is closed and 1 if it is open (type smallint). When I try @bugs = Bug.find_all_by_fOpen(1), I get the following exception: undefined method `find_by_fOpen'' for Bug:Class But when I try @bugs = Bug.find(:all, :conditions => ["fOpen = ?", 1]), I get the expected find results. Any ideas? Thanks, Eden -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060105/89182e89/attachment.html
BigSmoke
2006-Jan-05 23:40 UTC
[Rails] Repost - Do dynamic finders work with legacy schemas?
On 1/5/06, Eden Brandeis <ebrandeis@gmail.com> wrote:> Hello everyone, > > I have another question related to a legacy schema I am working with. > > Do dynamic finders work with legacy schemas in general? The schema I am > working with uses hungarian prefixes for column names. For example fOpen is > 0 if a bug is closed and 1 if it is open (type smallint). When I try @bugs > = Bug.find_all_by_fOpen(1), I get the following exception: > > undefined method `find_by_fOpen'' for Bug:Class > > But when I try @bugs = Bug.find(:all, :conditions => ["fOpen = ?", 1]), I > get the expected find results. > > Any ideas?May I ask which DBMS you''re using (PgSQL, MySQL, Firebird, ...)? - Rowan -- Morality is usually taught by the immoral.
Eden Brandeis
2006-Jan-05 23:43 UTC
[Rails] Repost - Do dynamic finders work with legacy schemas?
I am connecting to MS SQL server from linux using freeTDS and the ODBC layers. On 1/5/06, BigSmoke <bigsmoke@gmail.com> wrote:> > On 1/5/06, Eden Brandeis <ebrandeis@gmail.com> wrote: > > Hello everyone, > > > > I have another question related to a legacy schema I am working with. > > > > Do dynamic finders work with legacy schemas in general? The schema I > am > > working with uses hungarian prefixes for column names. For example > fOpen is > > 0 if a bug is closed and 1 if it is open (type smallint). When I try > @bugs > > = Bug.find_all_by_fOpen(1), I get the following exception: > > > > undefined method `find_by_fOpen'' for Bug:Class > > > > But when I try @bugs = Bug.find(:all, :conditions => ["fOpen = ?", 1]), > I > > get the expected find results. > > > > Any ideas? > > May I ask which DBMS you''re using (PgSQL, MySQL, Firebird, ...)? > > - Rowan > > -- > Morality is usually taught by the immoral. > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060105/bb2ec285/attachment.html
BigSmoke
2006-Jan-06 01:49 UTC
[Rails] Repost - Do dynamic finders work with legacy schemas?
What does Bug.column_names return? - Rowan On 1/6/06, Eden Brandeis <ebrandeis@gmail.com> wrote:> I am connecting to MS SQL server from linux using freeTDS and the ODBC > layers. > > > On 1/5/06, BigSmoke <bigsmoke@gmail.com > wrote: > > > > On 1/5/06, Eden Brandeis <ebrandeis@gmail.com > wrote: > > > Hello everyone, > > > > > > I have another question related to a legacy schema I am working with. > > > > > > Do dynamic finders work with legacy schemas in general? The schema I > am > > > working with uses hungarian prefixes for column names. For example > fOpen is > > > 0 if a bug is closed and 1 if it is open (type smallint). When I try > @bugs > > > = Bug.find_all_by_fOpen(1), I get the following exception: > > > > > > undefined method `find_by_fOpen'' for Bug:Class > > > > > > But when I try @bugs = Bug.find(:all, :conditions => ["fOpen = ?", 1]), > I > > > get the expected find results. > > > > > > Any ideas? > > > > May I ask which DBMS you''re using (PgSQL, MySQL, Firebird, ...)?-- Morality is usually taught by the immoral.
Eden Brandeis
2006-Jan-09 18:49 UTC
[Rails] Repost - Do dynamic finders work with legacy schemas?
Rowan, Thanks for helping me out with this. Bug.column_names returns and empty array [ ]. On 1/5/06, BigSmoke <bigsmoke@gmail.com> wrote:> > What does Bug.column_names return? > > - Rowan > > On 1/6/06, Eden Brandeis <ebrandeis@gmail.com> wrote: > > I am connecting to MS SQL server from linux using freeTDS and the ODBC > > layers. > > > > > > On 1/5/06, BigSmoke <bigsmoke@gmail.com > wrote: > > > > > > On 1/5/06, Eden Brandeis <ebrandeis@gmail.com > wrote: > > > > Hello everyone, > > > > > > > > I have another question related to a legacy schema I am working > with. > > > > > > > > Do dynamic finders work with legacy schemas in general? The schema > I > > am > > > > working with uses hungarian prefixes for column names. For example > > fOpen is > > > > 0 if a bug is closed and 1 if it is open (type smallint). When I > try > > @bugs > > > > = Bug.find_all_by_fOpen(1), I get the following exception: > > > > > > > > undefined method `find_by_fOpen'' for Bug:Class > > > > > > > > But when I try @bugs = Bug.find(:all, :conditions => ["fOpen = ?", > 1]), > > I > > > > get the expected find results. > > > > > > > > Any ideas? > > > > > > May I ask which DBMS you''re using (PgSQL, MySQL, Firebird, ...)? > > -- > Morality is usually taught by the immoral. > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060109/35da0c48/attachment.html
BigSmoke
2006-Jan-11 17:55 UTC
[Rails] Repost - Do dynamic finders work with legacy schemas?
Hi, I suspect that your problem is caused by a bug or a misconfiguration in your ODBC driver or by a bug in the ActiveRecord adapter for ODBC. Does the user as which you''re connecting to the MS SQL server have access to the information_schema? You could test this by connecting to it as that user using an ODBC test program and issuing "select * from information_schema.columns". If it happens that you can''t get it, AR won''t get it. I''m not even sure if it is possible to restrict acces to the information_schema, but I''m having trouble coming up with a logical reason. Perhaps an AR developer can chip in and make a wild guess at why Model.column_names wouldn''t return anything while raw queries do? To me it sounds as if AR either doesn''t try or doesn''t succeed in reading the information_schema. - Rowan On 1/9/06, Eden Brandeis <ebrandeis@gmail.com> wrote:> > Rowan, > > Thanks for helping me out with this. Bug.column_names returns and empty > array [ ]. > > On 1/5/06, BigSmoke <bigsmoke@gmail.com > wrote: > > > > What does Bug.column_names return? > > > > - Rowan > > > > On 1/6/06, Eden Brandeis < ebrandeis@gmail.com> wrote: > > > I am connecting to MS SQL server from linux using freeTDS and the ODBC > > > layers. > > > > > > > > > On 1/5/06, BigSmoke < bigsmoke@gmail.com > wrote: > > > > > > > > On 1/5/06, Eden Brandeis <ebrandeis@gmail.com > wrote: > > > > > Hello everyone, > > > > > > > > > > I have another question related to a legacy schema I am working > > with. > > > > > > > > > > Do dynamic finders work with legacy schemas in general? The > > schema I > > > am > > > > > working with uses hungarian prefixes for column names. For > > example > > > fOpen is > > > > > 0 if a bug is closed and 1 if it is open (type smallint). When I > > try > > > @bugs > > > > > = Bug.find_all_by_fOpen(1), I get the following exception: > > > > > > > > > > undefined method `find_by_fOpen'' for Bug:Class > > > > > > > > > > But when I try @bugs = Bug.find(:all, :conditions => ["fOpen > > ?", 1]), > > > I > > > > > get the expected find results. > > > > > > > > > > Any ideas? > > > > > > > > May I ask which DBMS you''re using (PgSQL, MySQL, Firebird, ...)? > > > >-- Morality is usually taught by the immoral. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060111/bb0ddb1b/attachment.html
Eden Brandeis
2006-Jan-11 18:28 UTC
[Rails] Repost - Do dynamic finders work with legacy schemas?
Using isql to logon to the db, I get 350 rows from "select * from information_schema.columns". On 1/11/06, BigSmoke <bigsmoke@gmail.com> wrote:> > Hi, > > I suspect that your problem is caused by a bug or a misconfiguration in > your ODBC driver or by a bug in the ActiveRecord adapter for ODBC. > > Does the user as which you''re connecting to the MS SQL server have access > to the information_schema? You could test this by connecting to it as that > user using an ODBC test program and issuing " select * from > information_schema.columns". If it happens that you can''t get it, AR won''t > get it. I''m not even sure if it is possible to restrict acces to the > information_schema, but I''m having trouble coming up with a logical reason. > > Perhaps an AR developer can chip in and make a wild guess at why > Model.column_names wouldn''t return anything while raw queries do? To me it > sounds as if AR either doesn''t try or doesn''t succeed in reading the > information_schema. > > - Rowan > > On 1/9/06, Eden Brandeis <ebrandeis@gmail.com> wrote: > > > > Rowan, > > > > Thanks for helping me out with this. Bug.column_names returns and empty > > array [ ]. > > > > On 1/5/06, BigSmoke < bigsmoke@gmail.com > wrote: > > > > > > What does Bug.column_names return? > > > > > > - Rowan > > > > > > On 1/6/06, Eden Brandeis < ebrandeis@gmail.com> wrote: > > > > I am connecting to MS SQL server from linux using freeTDS and the > > > ODBC > > > > layers. > > > > > > > > > > > > On 1/5/06, BigSmoke < bigsmoke@gmail.com > wrote: > > > > > > > > > > On 1/5/06, Eden Brandeis <ebrandeis@gmail.com > wrote: > > > > > > Hello everyone, > > > > > > > > > > > > I have another question related to a legacy schema I am working > > > with. > > > > > > > > > > > > Do dynamic finders work with legacy schemas in general? The > > > schema I > > > > am > > > > > > working with uses hungarian prefixes for column names. For > > > example > > > > fOpen is > > > > > > 0 if a bug is closed and 1 if it is open (type smallint). When > > > I try > > > > @bugs > > > > > > = Bug.find_all_by_fOpen(1), I get the following exception: > > > > > > > > > > > > undefined method `find_by_fOpen'' for Bug:Class > > > > > > > > > > > > But when I try @bugs = Bug.find(:all, :conditions => ["fOpen > > > ?", 1]), > > > > I > > > > > > get the expected find results. > > > > > > > > > > > > Any ideas? > > > > > > > > > > May I ask which DBMS you''re using (PgSQL, MySQL, Firebird, ...)? > > > > > > > -- > Morality is usually taught by the immoral. > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060111/b15fc68e/attachment.html
BigSmoke
2006-Jan-11 19:25 UTC
[Rails] Repost - Do dynamic finders work with legacy schemas?
Clearly your ODBC configuration is working just fine. I think you should "Contribute [a] New Ticket" at http://dev.rubyonrails.org/ This has all the looks of an Active Record issue. I think it''s a good idea to refer to this thread for clarification and perhaps post a link to the new ticket in this thread. - Rowan On 1/11/06, Eden Brandeis <ebrandeis@gmail.com> wrote:> > Using isql to logon to the db, I get 350 rows from "select * from > information_schema.columns". > > On 1/11/06, BigSmoke < bigsmoke@gmail.com> wrote: > > > Hi, > > > > I suspect that your problem is caused by a bug or a misconfiguration in > > your ODBC driver or by a bug in the ActiveRecord adapter for ODBC. > > > > Does the user as which you''re connecting to the MS SQL server have > > access to the information_schema? You could test this by connecting to it as > > that user using an ODBC test program and issuing " select * from > > information_schema.columns". If it happens that you can''t get it, AR > > won''t get it. I''m not even sure if it is possible to restrict acces to the > > information_schema, but I''m having trouble coming up with a logical reason. > > > > Perhaps an AR developer can chip in and make a wild guess at why > > Model.column_names wouldn''t return anything while raw queries do? To me > > it sounds as if AR either doesn''t try or doesn''t succeed in reading the > > information_schema. > > > > - Rowan > > > > On 1/9/06, Eden Brandeis < ebrandeis@gmail.com> wrote: > > > > > > Rowan, > > > > > > Thanks for helping me out with this. Bug.column_names returns and > > > empty array [ ]. > > > > > > On 1/5/06, BigSmoke < bigsmoke@gmail.com > wrote: > > > > > > > > What does Bug.column_names return? > > > > > > > > - Rowan > > > > > > > > On 1/6/06, Eden Brandeis < ebrandeis@gmail.com> wrote: > > > > > I am connecting to MS SQL server from linux using freeTDS and the > > > > ODBC > > > > > layers. > > > > > > > > > > > > > > > On 1/5/06, BigSmoke < bigsmoke@gmail.com > wrote: > > > > > > > > > > > > On 1/5/06, Eden Brandeis <ebrandeis@gmail.com > wrote: > > > > > > > Hello everyone, > > > > > > > > > > > > > > I have another question related to a legacy schema I am > > > > working with. > > > > > > > > > > > > > > Do dynamic finders work with legacy schemas in general? The > > > > schema I > > > > > am > > > > > > > working with uses hungarian prefixes for column names. For > > > > example > > > > > fOpen is > > > > > > > 0 if a bug is closed and 1 if it is open (type > > > > smallint). When I try > > > > > @bugs > > > > > > > = Bug.find_all_by_fOpen(1), I get the following exception: > > > > > > > > > > > > > > undefined method `find_by_fOpen'' for Bug:Class > > > > > > > > > > > > > > But when I try @bugs = Bug.find(:all, :conditions => ["fOpen > > > > = ?", 1]), > > > > > I > > > > > > > get the expected find results. > > > > > > > > > > > > > > Any ideas? > > > > > > > > > > > > May I ask which DBMS you''re using (PgSQL, MySQL, Firebird, ...)? > > > > > > >-- Morality is usually taught by the immoral. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060111/e6fe4dc7/attachment-0001.html
Eden Brandeis
2006-Jan-11 23:27 UTC
[Rails] Repost - Do dynamic finders work with legacy schemas?
Thanks again for your help. I created the following ticket as suggested: Ticket #3452 (defect) Opened 1 second ago Dynamic finders not working with legacy database Status: *new* Reported by: ebrandeis Assigned to: David Priority: normal Milestone: Component: ActiveRecord Version: 1.0.0 Severity: normal Keywords: dynamic finder legacy schema Cc: I am using freeTDS and ODBC on FC4 to access a legacy MSSQL server DB. The schema I am working with uses hungarian prefixes for column names. For example fOpen is 0 if a bug is closed and 1 if it is open (type smallint). When I try @bugs = Bug.find_all_by_fOpen(1), I get the following exception: undefined method `find_by_fOpen'' for Bug:Class But when I try @bugs = Bug.find(:all, :conditions => ["fOpen = ?", 1]), I get the expected find results. I raised this issue on the rails mailing list (rails@lists.rubyonrails.org) under the thread "Repost - Do dynamic finders work with legacy schemas?". One reader (Rowan) had me check Bug.column_names and I found that it returns an empty array []. I tried the query "select * from information_schema.columns" using isql and got 350 rows, so it seems my DB connection configuration is correct. Is this an ActiveRecord?<http://dev.rubyonrails.org/wiki/ActiveRecord>issue? On 1/11/06, BigSmoke <bigsmoke@gmail.com> wrote:> > Clearly your ODBC configuration is working just fine. I think you should > "Contribute [a] New Ticket" at http://dev.rubyonrails.org/ > This has all the looks of an Active Record issue. I think it''s a good idea > to refer to this thread for clarification and perhaps post a link to the new > ticket in this thread. > > - Rowan > > On 1/11/06, Eden Brandeis <ebrandeis@gmail.com> wrote: > > > > Using isql to logon to the db, I get 350 rows from "select * from > > information_schema.columns". > > > > On 1/11/06, BigSmoke < bigsmoke@gmail.com> wrote: > > > > > Hi, > > > > > > I suspect that your problem is caused by a bug or a misconfiguration > > > in your ODBC driver or by a bug in the ActiveRecord adapter for ODBC. > > > > > > Does the user as which you''re connecting to the MS SQL server have > > > access to the information_schema? You could test this by connecting to it as > > > that user using an ODBC test program and issuing " select * from > > > information_schema.columns". If it happens that you can''t get it, AR > > > won''t get it. I''m not even sure if it is possible to restrict acces to the > > > information_schema, but I''m having trouble coming up with a logical reason. > > > > > > Perhaps an AR developer can chip in and make a wild guess at why > > > Model.column_names wouldn''t return anything while raw queries do? To > > > me it sounds as if AR either doesn''t try or doesn''t succeed in reading the > > > information_schema. > > > > > > - Rowan > > > > > > On 1/9/06, Eden Brandeis < ebrandeis@gmail.com> wrote: > > > > > > > > Rowan, > > > > > > > > Thanks for helping me out with this. Bug.column_names returns and > > > > empty array [ ]. > > > > > > > > On 1/5/06, BigSmoke < bigsmoke@gmail.com > wrote: > > > > > > > > > > What does Bug.column_names return? > > > > > > > > > > - Rowan > > > > > > > > > > On 1/6/06, Eden Brandeis < ebrandeis@gmail.com> wrote: > > > > > > I am connecting to MS SQL server from linux using freeTDS and > > > > > the ODBC > > > > > > layers. > > > > > > > > > > > > > > > > > > On 1/5/06, BigSmoke < bigsmoke@gmail.com > wrote: > > > > > > > > > > > > > > On 1/5/06, Eden Brandeis <ebrandeis@gmail.com > wrote: > > > > > > > > Hello everyone, > > > > > > > > > > > > > > > > I have another question related to a legacy schema I am > > > > > working with. > > > > > > > > > > > > > > > > Do dynamic finders work with legacy schemas in > > > > > general? The schema I > > > > > > am > > > > > > > > working with uses hungarian prefixes for column names. For > > > > > example > > > > > > fOpen is > > > > > > > > 0 if a bug is closed and 1 if it is open (type > > > > > smallint). When I try > > > > > > @bugs > > > > > > > > = Bug.find_all_by_fOpen(1), I get the following exception: > > > > > > > > > > > > > > > > undefined method `find_by_fOpen'' for Bug:Class > > > > > > > > > > > > > > > > But when I try @bugs = Bug.find(:all, :conditions => > > > > > ["fOpen = ?", 1]), > > > > > > I > > > > > > > > get the expected find results. > > > > > > > > > > > > > > > > Any ideas? > > > > > > > > > > > > > > May I ask which DBMS you''re using (PgSQL, MySQL, Firebird, > > > > > ...)? > > > > > > > > > > > -- > Morality is usually taught by the immoral. > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060111/afec2e94/attachment.html
Possibly Parallel Threads
- Checking the existance of a NOT NULL constraint from Active Record
- [Prototype] Why doesn''t calling submit() on a form result in the execution of the onsubmit event handler?
- Using mocks
- SwitchTower and Subversion branches
- Are migrations executed within a transaction?