Skip to content

Postgresql dialect should support CREATE TABLE AS #2086

Closed
@ilyabo

Description

@ilyabo

Describe the bug
Postgres should support CREATE TABLE AS

Database Engine
PostgreSQL

To Reproduce

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>node-sql-parser</title>
    <meta charset="utf-8" />
  </head>
  <body>
    <pre id="query"></pre>
    <script src="https://unpkg.com/node-sql-parser@5.3.1/umd/index.umd.js"></script>
    <script>
      window.onload = function () {
        // Example parser
        const parser = new NodeSQLParser.Parser();
        const ast = parser.astify('create table test as select 1', {
          database: 'postgresql',
        });
        console.log(ast);
        document.getElementById('query').innerHTML =
          'Query: ' + parser.sqlify(ast);
        document.body.innerHTML += `<pre>${JSON.stringify(ast, null, 2)}</pre>`;
        const sql = parser.sqlify(ast);
        console.log(sql);
      };
    </script>
  </body>
</html>

Expected behavior
Should be able to parse the query

Screenshots
image

Additional context
Same query parses well when using mysql:

image

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions