teo_sql_connector/stmts/alter_table/
add.rs1use crate::schema::column::SQLColumn;
2use crate::schema::dialect::SQLDialect;
3use crate::schema::value::encode::ToSQLString;
4
5pub struct SQLAlterTableAddStatement {
6 pub(crate) table: String,
7 pub(crate) column_def: SQLColumn,
8}
9
10impl ToSQLString for SQLAlterTableAddStatement {
11 fn to_string(&self, dialect: SQLDialect) -> String {
12 let table = &self.table;
13 let def = self.column_def.to_string(dialect);
14 let escape = if dialect == SQLDialect::PostgreSQL { "\"" } else { "`" };
15 format!("ALTER TABLE {escape}{table}{escape} ADD {def}")
16 }
17}