Skip to content

Support OnUpdate Function #684

Description

@Jinovate

Description

In MySQl, it supports ON UPDATE CURRENT_TIMESTAMP Function when creating table and declaring DATETIME column. But I wonder if there is non-Token::LParen option in Keyword::CURRENT_TIMESTAMP. "CURRENT_TIMESTAMP()" in Following Task passed but "CURRENT_TIMESTAMP" is not working

Task

#[test]
fn parse_table_colum_option_on_update() {
    let sql1 = "CREATE TABLE foo (`modification_time` DATETIME ON UPDATE CURRENT_TIMESTAMP())";
    match mysql().verified_stmt(sql1) {
        Statement::CreateTable { name, columns, .. } => {
            assert_eq!(name.to_string(), "foo");
            assert_eq!(
                vec![ColumnDef {
                    name: Ident::with_quote('`', "modification_time"),
                    data_type: DataType::Datetime,
                    collation: None,
                    options: vec![ColumnOptionDef {
                        name: None,
                        option: ColumnOption::OnUpdate(Expr::Function(Function {
                            name: ObjectName(vec![Ident::new("CURRENT_TIMESTAMP")]),
                            args: vec![],
                            over: None,
                            distinct: false,
                            special: false,
                        })),
                    },],
                }],
                columns
            );
        }
        _ => unreachable!(),
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions