Skip to content

Commit 866dbe6

Browse files
committed
refactor: update index creation to use IndexColumn type
- Change columns parameter type from OrderByExpr to IndexColumn - Update field access from .expr to .column for index columns - Fix AddConstraint pattern matching syntax for newer sqlparser version Signed-off-by: Svetlin Ralchev <iamralch@users.noreply.github.com>
1 parent b82093a commit 866dbe6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/schema.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,15 +245,18 @@ impl SchemaDef {
245245
&mut self,
246246
name: Option<ObjectName>,
247247
table_name: ObjectName,
248-
columns: Vec<sqlparser::ast::OrderByExpr>,
248+
indices: Vec<sqlparser::ast::IndexColumn>,
249249
unique: bool,
250250
) -> Result<(), String> {
251251
let table_name_str = object_name_to_string(&table_name);
252252

253253
if let Some(index_name) = name {
254254
let index = IndexDef {
255255
name: object_name_to_string(&index_name),
256-
columns: columns.iter().map(|col| format!("{}", col.expr)).collect(),
256+
columns: indices
257+
.iter()
258+
.map(|index| format!("{}", index.column))
259+
.collect(),
257260
unique,
258261
};
259262

@@ -274,7 +277,8 @@ impl SchemaDef {
274277
let table_name = object_name_to_string(&name);
275278

276279
for operation in operations {
277-
if let sqlparser::ast::AlterTableOperation::AddConstraint(constraint) = operation {
280+
if let sqlparser::ast::AlterTableOperation::AddConstraint { constraint, .. } = operation
281+
{
278282
if let Some(table_schema) = self.tables.get_mut(&table_name) {
279283
match constraint {
280284
TableConstraint::PrimaryKey { name, columns, .. } => {

0 commit comments

Comments
 (0)