(sql: str)
| 180 | |
| 181 | |
| 182 | def _replace_sqlite_datetime_functions(sql: str) -> str: |
| 183 | def replace_interval(match: re.Match[str]) -> str: |
| 184 | amount = match.group(1) |
| 185 | unit = match.group(2) |
| 186 | return f"to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC') + INTERVAL '{amount} {unit}', 'YYYY-MM-DD\"T\"HH24:MI:SS.US\"Z\"')" |
| 187 | |
| 188 | sql = _SQLITE_INTERVAL_PATTERN.sub(replace_interval, sql) |
| 189 | sql = _SQLITE_NOW_PATTERN.sub(_POSTGRES_NOW_TEXT_SQL, sql) |
| 190 | return sql |
| 191 | |
| 192 | |
| 193 | def _adapt_sql_for_postgres(sql: str) -> str: |
no outgoing calls
no test coverage detected