Michael Bayer wrote:
any dropping of "AS" for alisases has to occur locally within the firebird dialect;

That's of course what I meant.

feel free to send a patch.  I have no test instance of firebird here

I'm attaching two patches, one that enables the test frameword for firebird, and one the implements this fix, with a simple test.

ciao, lele.
Fri Oct  6 17:35:51 CEST 2006  [EMAIL PROTECTED]
  * Add firebird as one possible test target
diff -rN -u old-sqlalchemy-firebird/test/testbase.py new-sqlalchemy-firebird/test/testbase.py
--- old-sqlalchemy-firebird/test/testbase.py	2006-10-06 17:38:31.000000000 +0200
+++ new-sqlalchemy-firebird/test/testbase.py	2006-10-06 17:38:31.000000000 +0200
@@ -40,7 +40,7 @@
 
     parser = optparse.OptionParser(usage = "usage: %prog [options] files...")
     parser.add_option("--dburi", action="store", dest="dburi", help="database uri (overrides --db)")
-    parser.add_option("--db", action="store", dest="db", default="sqlite", help="prefab database uri (sqlite, sqlite_file, postgres, mysql, oracle, oracle8, mssql)")
+    parser.add_option("--db", action="store", dest="db", default="sqlite", help="prefab database uri (sqlite, sqlite_file, postgres, mysql, oracle, oracle8, mssql, firebird)")
     parser.add_option("--mockpool", action="store_true", dest="mockpool", help="use mock pool")
     parser.add_option("--verbose", action="store_true", dest="verbose", help="full debug echoing")
     parser.add_option("--quiet", action="store_true", dest="quiet", help="be totally quiet")
@@ -75,9 +75,11 @@
             opts = {'use_ansi':False}
         elif DBTYPE == 'mssql':
             db_uri = 'mssql://scott:[EMAIL PROTECTED]/test'
+        elif DBTYPE == 'firebird':
+            db_uri = 'firebird://sysdba:[EMAIL PROTECTED]/tmp/test.fdb'
 
     if not db_uri:
-        raise "Could not create engine.  specify --db <sqlite|sqlite_file|postgres|mysql|oracle|oracle8|mssql> to test runner."
+        raise "Could not create engine.  specify --db <sqlite|sqlite_file|postgres|mysql|oracle|oracle8|mssql|firebird> to test runner."
 
     if not options.nothreadlocal:
         __import__('sqlalchemy.mods.threadlocal')

Fri Oct  6 17:36:53 CEST 2006  [EMAIL PROTECTED]
  * Override visit_alias() for firebird, to avoid the "AS" keyword with table aliases
diff -rN -u old-sqlalchemy-firebird/lib/sqlalchemy/databases/firebird.py new-sqlalchemy-firebird/lib/sqlalchemy/databases/firebird.py
--- old-sqlalchemy-firebird/lib/sqlalchemy/databases/firebird.py	2006-10-06 17:39:21.000000000 +0200
+++ new-sqlalchemy-firebird/lib/sqlalchemy/databases/firebird.py	2006-10-06 17:39:21.000000000 +0200
@@ -314,6 +314,12 @@
         super(FBCompiler, self).__init__(dialect, statement, parameters, **kwargs)
         
       
+    def visit_alias(self, alias):
+        # Override to not use the AS keyword which FB 1.5 does not like
+        self.froms[alias] = self.get_from_text(alias.original) + " " + self.preparer.format_alias(alias)
+        self.strings[alias] = self.get_str(alias.original)
+
+
     def visit_column(self, column):
         return ansisql.ANSICompiler.visit_column(self, column)
             
diff -rN -u old-sqlalchemy-firebird/test/sql/select.py new-sqlalchemy-firebird/test/sql/select.py
--- old-sqlalchemy-firebird/test/sql/select.py	2006-10-06 17:39:21.000000000 +0200
+++ new-sqlalchemy-firebird/test/sql/select.py	2006-10-06 17:39:21.000000000 +0200
@@ -1,7 +1,7 @@
 from testbase import PersistTest
 import testbase
 from sqlalchemy import *
-from sqlalchemy.databases import sqlite, postgres, mysql, oracle
+from sqlalchemy.databases import sqlite, postgres, mysql, oracle, firebird
 import unittest, re
 
 # the select test now tests almost completely with TableClause/ColumnClause objects,
@@ -264,9 +264,14 @@
     def testalias(self):
         # test the alias for a table1.  column names stay the same, table name "changes" to "foo".
         self.runtest(
-        select([alias(table1, 'foo')])
-        ,"SELECT foo.myid, foo.name, foo.description FROM mytable AS foo")
+            select([alias(table1, 'foo')])
+            ,"SELECT foo.myid, foo.name, foo.description FROM mytable AS foo")
     
+        self.runtest(
+            select([alias(table1, 'foo')])
+            ,"SELECT foo.myid, foo.name, foo.description FROM mytable foo"
+            ,dialect=firebird.dialect())
+
         # create a select for a join of two tables.  use_labels means the column names will have
         # labels tablename_columnname, which become the column keys accessible off the Selectable object.
         # also, only use one column from the second table and all columns from the first table1.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to