darold / ora2pg

Ora2Pg is a free tool used to migrate an Oracle database to a PostgreSQL compatible schema. It connects your Oracle database, scan it automatically and extracts its structure or data, it then generates SQL scripts that you can load into PostgreSQL.
http://www.ora2pg.com/
GNU General Public License v3.0
1.02k stars 343 forks source link

Incorrect parsing of views involving functions in MYSQL #1576

Closed shubham-yb closed 1 year ago

shubham-yb commented 1 year ago

Hi Team, If we have a view in MYSQL and it involves a function without any alias provided for it, we export it as is for the alias which in turn is an invalid syntax for PG. It'll be clearer with an example:

Sample view definition:

CREATE OR REPLACE VIEW v1 as select foo(id) from bar;

where foo() is any function which returns something.

This is exported as:

CREATE OR REPLACE VIEW v1 AS select foo(bar.id) AS foo(id) FROM bar;

This is an invalid syntax which throws an error:

ERROR:  syntax error at or near "("
LINE 1: ...TE OR REPLACE VIEW v1 AS select foo(bar.id) AS foo(id) FROM ...

The same view defined with alias as :

CREATE OR REPLACE VIEW v1 AS select foo(bar.id) AS p_name FROM bar;

Works fine.

Thank You for your help.

darold commented 1 year ago

Might be fixed, with current code output is CREATE OR REPLACE VIEW v1 AS select foo(id) FROM bar;