loopbackio / loopback-connector-cassandra

Cassandra connector for the LoopBack framework.
Other
13 stars 22 forks source link

migration failed drop multiple columns case #81

Closed whomobile closed 4 years ago

whomobile commented 5 years ago

Description/Steps to reproduce

migration tables that have multiple drop columns do not work.

Steps to reproduce

  1. create table model with 5 columns
  2. apply migration
  3. change table to have 2 columns
  4. apply alter model.
  5. check cassandra to confirm migration status

Link to reproduction sandbox

https://github.com/strongloop/loopback-connector-cassandra/blob/eb176bb71475276031e298d005aa05b4810f5a9a/lib/migration.js#L274

`

  if (actualFieldNotPresentInModel(actualField, model)) {

    sql.push('DROP ' + self.escapeName(actualField.column));

  }

`

it generates sql like

ALTER TABLE "abc" DROP "column3", DROP "column4", DROP "column5" and that will fail with line 1:42 mismatched input ',' expecting EOF (ALTER TABLE "abc" DROP "column3"[,]...), while from below cql, it should be DROP column | ( column_list )

https://docs.datastax.com/en/dse/6.0/cql/cql/cql_reference/cql_commands/cqlAlterTable.html

Expected result

DROP ("column3", "column4", "column5")

Additional information

https://docs.datastax.com/en/dse/6.0/cql/cql/cql_reference/cql_commands/cqlAlterTable.html https://github.com/strongloop/loopback-connector-cassandra/blob/eb176bb71475276031e298d005aa05b4810f5a9a/lib/migration.js#L274

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.