Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-44480

PostgreSQL QUuid for binding at QSqlQuery::bindValue

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • None
    • 5.4.0
    • SQL Support
    • None
    • Windows 7x64, MSVC 2013, PosgreSQL 9.3
    • 34014406baaeac3e9d49d5654ef57ac6540a17a8

    Description

      I need to use QUuid values as QSqlQuery::bindValue arguments like this:

      QSqlQuery q(db);
      bool ok = q.prepare("SELECT uuid('{C46A2575-7198-4C08-B4FD-C031B390E6E1}')=:test");
      q.bindValue(":test", QUuid("{C46A2575-7198-4C08-B4FD-C031B390E6E1}"));
      q.exec();
      qDebug() << q.lastError().databaseText();
      

      This generates invalid query text like

      SELECT uuid('{C46A2575-7198-4C08-B4FD-C031B390E6E1}')={C46A2575-7198-4C08-B4FD-C031B390E6E1}
      

      Error text is: ERROR: syntax error at or near "{"
      But the UUID values in PostgreSQL should be single-quoted

      I am attaching simple patch to solve the problem

      BTW, to use UUID in PostgreSQL you should create extension:

      CREATE EXTENSION "uuid-ossp"
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            buddenha Oswald Buddenhagen
            Evgeniy Fominov Evgeniy Fominov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes