Closed scootermon closed 2 years ago
As indicated in the title, the generated SQL for timestamp_with_time_zone_len columns isn't valid as the precision "argument" is placed after 'with time zone` rather than after 'timestamp'. For reference, see: https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-DATETIME-TABLE
timestamp_with_time_zone_len
Run the following migration:
use sea_schema::migration::prelude::*; #[derive(Iden)] enum Foo { Table, CreatedAt, } pub struct Migration; impl MigrationName for Migration { fn name(&self) -> &str { "bug-report" } } #[async_trait::async_trait] impl MigrationTrait for Migration { async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { manager .create_table( Table::create() .table(Foo::Table) .col(ColumnDef::new(Foo::CreatedAt).timestamp_with_time_zone_len(0)) .to_owned(), ) .await } async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { // not relevant Ok(()) } }
Should generate and execute the following SQL:
CREATE TABLE "foo" ( [...] "created_at" timestamp(0) with time zone, )
CREATE TABLE "foo" ( [...] "created_at" timestamp with time zone(0), ) Execution Error: error returned from database: syntax error at or near "("
│ └── sea-orm v0.7.1 │ ├── sea-orm-macros v0.7.0 (proc-macro) │ ├── sea-query v0.23.0 │ │ ├── sea-query-derive v0.2.0 (proc-macro) │ ├── sea-strum v0.23.0 │ │ └── sea-strum_macros v0.23.0 (proc-macro) │ └── sea-schema v0.7.1 │ ├── sea-orm v0.7.1 (*) │ ├── sea-query v0.22.0 │ │ └── sea-query-derive v0.2.0 (proc-macro) (*) │ ├── sea-schema-derive v0.1.0 (proc-macro)
Running against PostgreSQL 14.2 on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
PostgreSQL 14.2 on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
@scootermon thank you for the report, I create PR with fix: https://github.com/SeaQL/sea-query/pull/286
totally didn't know that. Thanks for reporting
Description
As indicated in the title, the generated SQL for
timestamp_with_time_zone_len
columns isn't valid as the precision "argument" is placed after 'with time zone` rather than after 'timestamp'. For reference, see: https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-DATETIME-TABLESteps to Reproduce
Run the following migration:
Expected Behavior
Should generate and execute the following SQL:
Actual Behavior
Versions
Running against
PostgreSQL 14.2 on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit