Repository navigation
Commit 07df830
authored
fix(sqlalchemy-bigquery): compile func.now() to CURRENT_TIMESTAMP (#18994)
Fixes #15762
BigQuery has no `NOW()` function, but `func.now()` compiled to `now()`
with this dialect, so queries and `server_default=func.now()` columns
failed in BigQuery.
This adds `visit_now_func` to `BigQueryCompiler` so `func.now()`
compiles to `CURRENT_TIMESTAMP`. That is what `func.current_timestamp()`
already compiles to here, and it matches how the SQLite, MSSQL and
Oracle dialects handle `now()`.
Added `test_now_compiles_to_current_timestamp` in
`tests/unit/test_compiler.py`, which fails on `main` (`SELECT now() AS
ts`) and passes with this change. The package's unit tests pass locally,
and the noxfile's ruff 0.14.14 checks, flake8 and black report nothing
on the changed files.
- [x] Make sure to open an issue as a bug/issue before writing your code
(#15762)
- [x] Ensure the tests and linter pass
- [x] Code coverage does not decrease
Co-authored-by: abhishekacharya200 <abhishekacharya200@users.noreply.github.com>1 parent a952b6b commit 07df830
2 files changed
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
588 | 588 | | |
589 | 589 | | |
590 | 590 | | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
591 | 595 | | |
592 | 596 | | |
593 | 597 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
491 | 491 | | |
492 | 492 | | |
493 | 493 | | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
494 | 501 | | |
495 | 502 | | |
496 | 503 | | |
| |||
0 commit comments