Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using PostgreSQL UUID column type in Propel as keys - not properly escaped in relation insert #1498

Closed
Kedarius opened this issue Sep 12, 2018 · 2 comments
Labels

Comments

@Kedarius
Copy link

I am trying to use PostgreSQL UUID column type as primary and foreign key. My schema looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<database name="videoarchive" defaultIdMethod="none">
   <table name="video" phpName="Video">
    <column name="id" type="varchar" required="true" primaryKey="true" sqlType="uuid" />
    <column name="title" type="varchar"  required="true" />
    <column name="description" type="varchar"  required="true" />    
    <column name="channel_id" type="varchar" required="true"  sqlType="uuid" />
    <foreign-key foreignTable="channel" phpName="Channel" refPhpName="Video">
      <reference local="channel_id" foreign="id"/>
    </foreign-key>
  </table>
  <table name="channel" phpName="Channel">
    <column name="id" type="varchar" required="true" primaryKey="true" sqlType="uuid" />
  <column name="title" type="varchar"  required="true" />
    <column name="description" type="varchar"  required="true" />        
  </table>
</database>

Creating and saving objects works fine:

 $c = new Channel();
 //set all properties of Channel object
 $c->setDescription('xxxxx');
 $c->save();

However when I try:

 $q = new ChannelQuery();
 $firstChannel = $q->findPK('be8d37ca-db94-4070-88e7-4a6690410a2e');
 $video=new Video();
 //set all properties of Video object
 $video->setChannelId($firstChannel);
 $video->save();

I do get SQL errors, because the channelId is not properly quoted:

[2018-09-13 00:48:04] defaultLogger.ERROR: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for uuid: "Id: be8d37ca-db94-4070-88e7-4a6690410a2e Title: 'xxx' Description: 'xxx' " [] []

However
$video->setChannelId($firstChannel->getId());
works fine.

Propel is installed from composer ( "propel/propel": "~2.0@dev", ), engine is PostgreSQL and PHP 5.6.
Just to be thorough I even tried changing type to binary in all UUID columns to no avail.

@dereuromark dereuromark added the Bug label Jul 1, 2020
@dereuromark
Copy link
Contributor

Is this still relevant or can it be closed?

@Kedarius
Copy link
Author

Sorry, the project where I needed it kinda died and I have no ability to check it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants