summaryrefslogtreecommitdiffstats
path: root/sqlglot/dialects/oracle.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-03-12 10:17:16 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-03-12 10:17:16 +0000
commit7457677bc603569692329e39a59ccb018306e2a6 (patch)
treebb16c8f909bfbf7ff272cd8ef14a413c47b203fe /sqlglot/dialects/oracle.py
parentReleasing debian version 11.3.3-1. (diff)
downloadsqlglot-7457677bc603569692329e39a59ccb018306e2a6.tar.xz
sqlglot-7457677bc603569692329e39a59ccb018306e2a6.zip
Merging upstream version 11.3.6.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/dialects/oracle.py')
-rw-r--r--sqlglot/dialects/oracle.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/sqlglot/dialects/oracle.py b/sqlglot/dialects/oracle.py
index 795bbeb..7028a04 100644
--- a/sqlglot/dialects/oracle.py
+++ b/sqlglot/dialects/oracle.py
@@ -4,7 +4,7 @@ import typing as t
from sqlglot import exp, generator, parser, tokens, transforms
from sqlglot.dialects.dialect import Dialect, no_ilike_sql, rename_func, trim_sql
-from sqlglot.helper import csv
+from sqlglot.helper import csv, seq_get
from sqlglot.tokens import TokenType
PASSING_TABLE_ALIAS_TOKENS = parser.Parser.TABLE_ALIAS_TOKENS - {
@@ -75,6 +75,7 @@ class Oracle(Dialect):
FUNCTIONS = {
**parser.Parser.FUNCTIONS, # type: ignore
"DECODE": exp.Matches.from_arg_list,
+ "SQUARE": lambda args: exp.Pow(this=seq_get(args, 0), expression=exp.Literal.number(2)),
}
FUNCTION_PARSERS: t.Dict[str, t.Callable] = {
@@ -82,8 +83,6 @@ class Oracle(Dialect):
"XMLTABLE": _parse_xml_table,
}
- INTEGER_DIVISION = False
-
def _parse_column(self) -> t.Optional[exp.Expression]:
column = super()._parse_column()
if column:
@@ -92,7 +91,6 @@ class Oracle(Dialect):
class Generator(generator.Generator):
LOCKING_READS_SUPPORTED = True
- INTEGER_DIVISION = False
TYPE_MAPPING = {
**generator.Generator.TYPE_MAPPING, # type: ignore
@@ -122,6 +120,7 @@ class Oracle(Dialect):
exp.TimeToStr: lambda self, e: f"TO_CHAR({self.sql(e, 'this')}, {self.format_time(e)})",
exp.UnixToTime: lambda self, e: f"TO_DATE('1970-01-01','YYYY-MM-DD') + ({self.sql(e, 'this')} / 86400)",
exp.Substring: rename_func("SUBSTR"),
+ exp.ToChar: lambda self, e: self.function_fallback_sql(e),
}
def query_modifiers(self, expression: exp.Expression, *sqls: str) -> str: