AnatolyUss / nmig

NMIG is a database migration tool, written in Node.js and highly inspired by FromMySqlToPostgreSql.
GNU General Public License v3.0
451 stars 83 forks source link

View is not created, syntax error #102

Closed robert-sjoblom closed 1 year ago

robert-sjoblom commented 1 year ago

Set up two databases.

MySQL: https://github.com/datacharmer/test_db Postgres: Empty

Move data from MySQL to Postgres.

Expected:

All views are created on PG side

Actual:

Query fails with message

--[ViewGenerator::default] error: syntax error at or near "("

    SQL: CREATE OR REPLACE VIEW "public"."current_dept_emp" AS select "l"."emp_no" AS "emp_no","d"."dept_no" AS "dept_no","l"."from_date" AS "from_date","l"."to_date" AS "to_date" from "public".("dept_emp" "d" join "public"."dept_emp_latest_date" "l" on((("d"."emp_no" = "l"."emp_no") and ("d"."from_date" = "l"."from_date") and ("l"."to_date" = "d"."to_date"))));
AnatolyFromPerion commented 1 year ago

nmig doesn't implement a real SQL parser, so it attempts to create a view in PostgreSQL with the original (MySQL) syntax. Sometimes, in simple cases, it works. Sometimes it doesn't. When it doesn't - nmig leaves a ditailed error log.