POSTGRES support - Syntax error while creating view

Created on 5 November 2020, over 3 years ago
Updated 13 August 2023, 11 months ago

Hello Guys,
I am new in Drupal 8 development. I am facing syntax error while creating view with Custom View Table module. My custom table name is "ct_event" and I am using PGSQL for my site. Currently I am using localhost for my site. Can anyone help me to figure out the error?

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇮🇳India Aishwary Singh India

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇹🇷Turkey Orkut Murat Yılmaz

    Hello all,

    The error log still exists, as I'm pasting below:

    Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "DESCRIBE" LINE 1: DESCRIBE mytable ^: DESCRIBE mytable; Array ( ) in Drupal\view_custom_table\Form\AddViewsCustomTable->buildForm() (line 202 of /var/www/html/tcv2/web/modules/contrib/view_custom_table/src/Form/AddViewsCustomTable.php).

    I think that the error's cause is the DESCRIBE command, which belongs to MySQL and not valid in PostgreSQL.

    We should override the error by using PostgreSQL commands.

    Best,
    Orkut

  • Status changed to Active about 1 year ago
  • 🇹🇷Turkey Orkut Murat Yılmaz

    Maybe we should modify the code for postgres like this:

    $connection = Database::getConnection('default', $databaseName);
    $schema = $connection->escapeString($schemaName);
    $table = $connection->escapeString($tableName);
    $text_query = "SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = '$schema' AND table_name = '$table'";
    $query = $connection->query($text_query);
  • 🇨🇦Canada joseph.olstad

    @Orkut Murat Yilmaz, have you tested #6 with Postgres ? does that fix the issue?

    I wonder if that would work with mysql also?

  • 🇹🇷Turkey Orkut Murat Yılmaz

    @joseph.olstad, thanks for your comments.

    I've tried adding a custom table with this module's 2.0.4 and 2.0.x-dev versions too, bug is still there in the recent log messages.

    The query on #6 works with PostgreSQL, but I am not sure it would work for both databases as well.

    Maybe we can add a control before adding it, in order to check which database is connected. Does it sound okay?

Production build 0.69.0 2024