Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed obscure Oracle quoting issues pointed out by the custom_columns…

…_regress test case.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9612 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 15bd6499403132fad93963253f6c679b20e0e00f 1 parent 453d452
Matt Boersma authored December 08, 2008

Showing 1 changed file with 9 additions and 9 deletions. Show diff stats Hide diff stats

  1. 18  django/db/backends/oracle/base.py
18  django/db/backends/oracle/base.py
@@ -49,17 +49,17 @@ def autoinc_sql(self, table, column):
49 49
                 SELECT COUNT(*) INTO i FROM USER_CATALOG
50 50
                     WHERE TABLE_NAME = '%(sq_name)s' AND TABLE_TYPE = 'SEQUENCE';
51 51
                 IF i = 0 THEN
52  
-                    EXECUTE IMMEDIATE 'CREATE SEQUENCE %(sq_name)s';
  52
+                    EXECUTE IMMEDIATE 'CREATE SEQUENCE "%(sq_name)s"';
53 53
                 END IF;
54 54
             END;
55 55
             /""" % locals()
56 56
         trigger_sql = """
57  
-            CREATE OR REPLACE TRIGGER %(tr_name)s
  57
+            CREATE OR REPLACE TRIGGER "%(tr_name)s"
58 58
             BEFORE INSERT ON %(tbl_name)s
59 59
             FOR EACH ROW
60 60
             WHEN (new.%(col_name)s IS NULL)
61 61
                 BEGIN
62  
-                    SELECT %(sq_name)s.nextval
  62
+                    SELECT "%(sq_name)s".nextval
63 63
                     INTO :new.%(col_name)s FROM dual;
64 64
                 END;
65 65
                 /""" % locals()
@@ -94,8 +94,8 @@ def field_cast_sql(self, db_type):
94 94
             return "%s"
95 95
 
96 96
     def last_insert_id(self, cursor, table_name, pk_name):
97  
-        sq_name = util.truncate_name(table_name, self.max_name_length() - 3)
98  
-        cursor.execute('SELECT %s_sq.currval FROM dual' % sq_name)
  97
+        sq_name = get_sequence_name(table_name)
  98
+        cursor.execute('SELECT "%s".currval FROM dual' % sq_name)
99 99
         return cursor.fetchone()[0]
100 100
 
101 101
     def lookup_cast(self, lookup_type):
@@ -403,12 +403,12 @@ def _get_sequence_reset_sql():
403 403
         BEGIN
404 404
             LOCK TABLE %(table)s IN SHARE MODE;
405 405
             SELECT NVL(MAX(%(column)s), 0) INTO startvalue FROM %(table)s;
406  
-            SELECT %(sequence)s.nextval INTO cval FROM dual;
  406
+            SELECT "%(sequence)s".nextval INTO cval FROM dual;
407 407
             cval := startvalue - cval;
408 408
             IF cval != 0 THEN
409  
-                EXECUTE IMMEDIATE 'ALTER SEQUENCE %(sequence)s MINVALUE 0 INCREMENT BY '||cval;
410  
-                SELECT %(sequence)s.nextval INTO cval FROM dual;
411  
-                EXECUTE IMMEDIATE 'ALTER SEQUENCE %(sequence)s INCREMENT BY 1';
  409
+                EXECUTE IMMEDIATE 'ALTER SEQUENCE "%(sequence)s" MINVALUE 0 INCREMENT BY '||cval;
  410
+                SELECT "%(sequence)s".nextval INTO cval FROM dual;
  411
+                EXECUTE IMMEDIATE 'ALTER SEQUENCE "%(sequence)s" INCREMENT BY 1';
412 412
             END IF;
413 413
             COMMIT;
414 414
         END;

0 notes on commit 15bd649

Please sign in to comment.
Something went wrong with that request. Please try again.