1414 TimestampTZ ,
1515 FractionalType ,
1616)
17- from ..abcs .mixins import AbstractMixin_MD5 , AbstractMixin_NormalizeValue
18- from .base import BaseDialect , ThreadedDatabase , import_helper , ConnectError , QueryError
17+ from ..abcs .mixins import AbstractMixin_MD5 , AbstractMixin_NormalizeValue , AbstractMixin_Schema
18+ from ..abcs import Compilable
19+ from ..queries import this , table , SKIP
20+ from .base import BaseDialect , ThreadedDatabase , import_helper , ConnectError , QueryError , Mixin_Schema
1921from .base import TIMESTAMP_PRECISION_POS
2022
2123SESSION_TIME_ZONE = None # Changed by the tests
@@ -57,8 +59,19 @@ def normalize_number(self, value: str, coltype: FractionalType) -> str:
5759 format_str += "0." + "9" * (coltype .precision - 1 ) + "0"
5860 return f"to_char({ value } , '{ format_str } ')"
5961
62+ class Mixin_Schema (AbstractMixin_Schema ):
63+ def list_tables (self , table_schema : str , like : Compilable = None ) -> Compilable :
64+ return (
65+ table ('ALL_TABLES' )
66+ .where (
67+ this .OWNER == table_schema ,
68+ this .TABLE_NAME .like (like ) if like is not None else SKIP ,
69+ )
70+ .select (table_name = this .TABLE_NAME )
71+ )
72+
6073
61- class Dialect (BaseDialect ):
74+ class Dialect (BaseDialect , Mixin_Schema ):
6275 name = "Oracle"
6376 SUPPORTS_PRIMARY_KEY = True
6477 TYPE_CLASSES : Dict [str , type ] = {
@@ -73,7 +86,7 @@ class Dialect(BaseDialect):
7386 ROUNDS_ON_PREC_LOSS = True
7487
7588 def quote (self , s : str ):
76- return f"{ s } "
89+ return f' "{ s } "'
7790
7891 def to_string (self , s : str ):
7992 return f"cast({ s } as varchar(1024))"
@@ -143,7 +156,7 @@ class Oracle(ThreadedDatabase):
143156 def __init__ (self , * , host , database , thread_count , ** kw ):
144157 self .kwargs = dict (dsn = f"{ host } /{ database } " if database else host , ** kw )
145158
146- self .default_schema = kw .get ("user" )
159+ self .default_schema = kw .get ("user" ). upper ()
147160
148161 super ().__init__ (thread_count = thread_count )
149162
@@ -168,5 +181,5 @@ def select_table_schema(self, path: DbPath) -> str:
168181
169182 return (
170183 f"SELECT column_name, data_type, 6 as datetime_precision, data_precision as numeric_precision, data_scale as numeric_scale"
171- f" FROM ALL_TAB_COLUMNS WHERE table_name = '{ table . upper () } ' AND owner = '{ schema . upper () } '"
184+ f" FROM ALL_TAB_COLUMNS WHERE table_name = '{ table } ' AND owner = '{ schema } '"
172185 )
0 commit comments