Re: Possible Bug for Oracle
On Nov 25, 2:55 pm, "Wesley Moore" <[EMAIL PROTECTED]> wrote: > On Wed, Nov 26, 2008 at 4:55 AM, Jeremy Evans <[EMAIL PROTECTED]> wrote: > > Thanks, > > applied:http://github.com/jeremyevans/sequel/commit/0c7c893c5093337008f59de68... > > > Do the Oracle adapter specs run correctly? Did you try running the > > integration tests with the Oracle adapter? > > > Jeremy > > I rand the adapter tests. There was a problem using DESC in the order by > method: > > NoMethodError in 'An Oracle dataset should return the correct records' > undefined method `DESC' for :value:Symbol > ./spec/adapters/oracle_spec.rb:75: > > NoMethodError in 'Joined Oracle dataset should return correct result' > undefined method `DESC' for :books__id:Symbol > ./spec/adapters/oracle_spec.rb:218: Symbol#DESC was removed in Sequel 2.0, so I just pushed a patch to change it to Symbol#desc: http://github.com/jeremyevans/sequel/commit/cde6c93d3dd1c29b7fb1229b513c0e060d5f334f. Hopefully that fixes the issue and the spec doesn't fail now. > I haven't run the integration tests, I'll do that later today. Thanks. Jeremy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to sequel-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en -~--~~~~--~~--~--~---
Re: Possible Bug for Oracle
On Wed, Nov 26, 2008 at 4:55 AM, Jeremy Evans <[EMAIL PROTECTED]> wrote: > Thanks, applied: > http://github.com/jeremyevans/sequel/commit/0c7c893c5093337008f59de6885bd682cf8d327b > > Do the Oracle adapter specs run correctly? Did you try running the > integration tests with the Oracle adapter? > > Jeremy I rand the adapter tests. There was a problem using DESC in the order by method: NoMethodError in 'An Oracle dataset should return the correct records' undefined method `DESC' for :value:Symbol ./spec/adapters/oracle_spec.rb:75: NoMethodError in 'Joined Oracle dataset should return correct result' undefined method `DESC' for :books__id:Symbol ./spec/adapters/oracle_spec.rb:218: I haven't run the integration tests, I'll do that later today. WM --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to sequel-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en -~--~~~~--~~--~--~---
Re: Possible Bug for Oracle
On Nov 24, 3:08 pm, "Wesley Moore" <[EMAIL PROTECTED]> wrote: > Based on the documentation > here:http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statem... > > It would appear that the 'AS' keyword is optional in the places where > the patch would have an affect. > > I tested the patch against commit > 8b395139f67ddcf7f24443cb6c1d7460e409f639 and appears to correct the > problem. > > I've attached a patch, which adds some rudimentary specs for the change. Thanks, applied: http://github.com/jeremyevans/sequel/commit/0c7c893c5093337008f59de6885bd682cf8d327b Do the Oracle adapter specs run correctly? Did you try running the integration tests with the Oracle adapter? Jeremy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to sequel-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en -~--~~~~--~~--~--~---
Re: Possible Bug for Oracle
Based on the documentation here: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_10002.htm#i2065646 It would appear that the 'AS' keyword is optional in the places where the patch would have an affect. I tested the patch against commit 8b395139f67ddcf7f24443cb6c1d7460e409f639 and appears to correct the problem. I've attached a patch, which adds some rudimentary specs for the change. Thanks, Wes On Tue, Nov 25, 2008 at 3:47 AM, Jeremy Evans <[EMAIL PROTECTED]> wrote: > > On Nov 23, 10:38 pm, "Wesley Moore" <[EMAIL PROTECTED]> wrote: >> The code in question from dataset/sql.rb is shown below. >> to_table_reference calls as_sql if an alias is supplied. The alias is >> supplied by source_list when selecting from a Dataset. This generates >> something like: ...FROM (sql) AS "T1". From what I can tell Oracle >> doesn't support aliasing sub-queries with AS, you just provide the >> alias E.g. ...FROM (sql) "T1" > > I don't use Oracle, so I can't test this, but here's a patch that may > work. It will omit the use of AS for every case where something is > aliased, so if there is any case where Oracle requires the use of AS, > it will break. If that is the case, we'll have to do some > refactoring. Anyway, please test this patch with the latest master > branch and let me know if it works. > > Thanks, > Jeremy > > diff --git a/lib/sequel_core/adapters/shared/oracle.rb b/lib/ > sequel_core/adapters/shared/oracle.rb > index f20b24b..425d48d 100644 > --- a/lib/sequel_core/adapters/shared/oracle.rb > +++ b/lib/sequel_core/adapters/shared/oracle.rb > @@ -21,6 +21,11 @@ module Sequel > > private > > + # SQL fragment for specifying an alias. expression should > already be literalized. > + def as_sql(expression, aliaz) > +"#{expression} #{quote_identifier(aliaz)}" > + end > + > def select_clause_order > SELECT_CLAUSE_ORDER > end > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to sequel-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en -~--~~~~--~~--~--~--- sequel-alias.patch Description: Binary data
Re: Possible Bug for Oracle
On Nov 23, 10:38 pm, "Wesley Moore" <[EMAIL PROTECTED]> wrote: > The code in question from dataset/sql.rb is shown below. > to_table_reference calls as_sql if an alias is supplied. The alias is > supplied by source_list when selecting from a Dataset. This generates > something like: ...FROM (sql) AS "T1". From what I can tell Oracle > doesn't support aliasing sub-queries with AS, you just provide the > alias E.g. ...FROM (sql) "T1" I don't use Oracle, so I can't test this, but here's a patch that may work. It will omit the use of AS for every case where something is aliased, so if there is any case where Oracle requires the use of AS, it will break. If that is the case, we'll have to do some refactoring. Anyway, please test this patch with the latest master branch and let me know if it works. Thanks, Jeremy diff --git a/lib/sequel_core/adapters/shared/oracle.rb b/lib/ sequel_core/adapters/shared/oracle.rb index f20b24b..425d48d 100644 --- a/lib/sequel_core/adapters/shared/oracle.rb +++ b/lib/sequel_core/adapters/shared/oracle.rb @@ -21,6 +21,11 @@ module Sequel private + # SQL fragment for specifying an alias. expression should already be literalized. + def as_sql(expression, aliaz) +"#{expression} #{quote_identifier(aliaz)}" + end + def select_clause_order SELECT_CLAUSE_ORDER end --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to sequel-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en -~--~~~~--~~--~--~---
Possible Bug for Oracle
Hi, I think I've encountered a bug when generating SQL for nested queries in Oracle. The problem is a combination of the as_sql method and the source_list method. I encountered the problem in 2.6.0, upgraded to 2.7.1 and found it still present, then checked Github and think its still present there. The code in question from dataset/sql.rb is shown below. to_table_reference calls as_sql if an alias is supplied. The alias is supplied by source_list when selecting from a Dataset. This generates something like: ...FROM (sql) AS "T1". From what I can tell Oracle doesn't support aliasing sub-queries with AS, you just provide the alias E.g. ...FROM (sql) "T1" 1 def to_table_reference(table_alias=nil) 2s = "(#{sql})" 3table_alias ? as_sql(s, table_alias) : s 4 end 5 6 private 7 8 # SQL fragment for specifying an alias. expression should already be literalized. 9 def as_sql(expression, aliaz) 10"#{expression} AS #{quote_identifier(aliaz)}" 11 end A contrived sample of reproducing this is: DB[:tab].select(:tabtype).group_by(:tabtype).count this produces the following SQL: SELECT * FROM (SELECT COUNT(*) FROM (SELECT "TABTYPE" FROM "TAB" GROUP BY "TABTYPE") AS "T1") WHERE ROWNUM <= 1 which raises this error: OCIError: ORA-00907: missing right parenthesis Removing the AS before "T1" permits the query to run properly. Hope this is a useful bug report and sorry for stepping trough the code if you know that already. Regards, Wes --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to sequel-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en -~--~~~~--~~--~--~---