and I had to escape all those backslashes:
String theSQL = "INSERT INTO person (active, firstname, lastname, username,
password, creationdate, id) VALUES " +
"(true, 'Ted', 'Petrosky', 'tedpet', '3368', now(), E'\\\\x" +
UUIDUtilities.generateAsNSData()._hexString() +"')”;
turned into:
INSERT INTO person (active, firstname, lastname, username, password,
creationdate, id) VALUES (true, 'Ted', 'Petrosky', 'tedpet', '3368', now(),
E'\\xFAADED2F9427486B849B67C7A07B73C1')
and I see in the backend:
companydirectory=# select * from person;
active | creationdate | firstname | id |
lastname | password | username
--------+--------------+-----------+------------------------------------+----------+------------------------------+----------
t | 2016-06-28 | Ted | \xfaaded2f9427486b849b67c7a07b73c1 |
Petrosky | nos3rVw+4jrSacbf8dfen8HMxPk= | tedpet
so I think I can go on from here.
thanks for the guidance.
Ted
> On Jun 28, 2016, at 12:43 PM, Ramsey Gurley <[email protected]> wrote:
>
> https://www.postgresql.org/docs/9.0/static/datatype-binary.html
> <https://www.postgresql.org/docs/9.0/static/datatype-binary.html>
>
> bytea_output used to be escape by default. Somewhere along the way they
> changed it to hex. I find setting it to escape makes our WO things work
> properly.
>
> On Jun 28, 2016, at 6:52 AM, Theodore Petrosky <[email protected]> wrote:
>
>>
>> INSERT INTO person (firstname, lastname, id) VALUES ('Ted', 'Petrosky',
>> E'021D57D63ED54328A5411B07442E262E')
>>
>> this is what shows up in the database:
>> \x3032314435374436334544353433323841353431314230373434324532363245
>>
>>
>> INSERT INTO person (firstname, lastname, id) VALUES ('Ted', 'Petrosky',
>> decode(E'F84B2A6880C948F4959EDB5FCF5347FE', 'hex'))
>>
>> this is what shows up in the database: \xf84b2a6880c948f4959edb5fcf5347fe
>>
>>
>> so, it looks like the full decode statement is necessary.
>>
>>
>> Ted
>>
>>
>>> On Jun 28, 2016, at 8:32 AM, Samuel Pelletier <[email protected]
>>> <mailto:[email protected]>> wrote:
>>>
>>> Ted,
>>>
>>> They are probably 10 of other variations of this code but I do not think
>>> there is any best way, the data needs to be converted to hex for the SQL.
>>>
>>> I'm sot sure if the "decode(E'...')" part is required, based on pg doc,
>>> byte constant can be written as "E'\\xDEADBEEF' <smb://xDEADBEEF'>" so
>>> "E'\\x <smb://x>" + UUIDUtilities.generateAsNSData()._hexString() + "'"
>>> should also works.
>>>
>>> Samuel
>>>
>>>
>>>> Le 28 juin 2016 à 06:09, Theodore Petrosky <[email protected]
>>>> <mailto:[email protected]>> a écrit :
>>>>
>>>> I am starting a new little project and I want to use the UUIDs. My
>>>> migrations usually start up by inserting a few entities by executing some
>>>> SQL.
>>>>
>>>> The id column is not a ‘real’ postgresql UUID, it is a 128 bit bytea
>>>> column. I figured out a way to use UUIDUtilities.generateAsNSData use that
>>>> value to insert my entity.
>>>>
>>>> String theSQL = "INSERT INTO person (active, firstname, creationdate, id)
>>>> VALUES " +
>>>> "(true, 'Ted', now(), decode(E'" +
>>>> UUIDUtilities.generateAsNSData()._hexString() + "', 'hex'))";
>>>>
>>>> ERXJDBCUtilities.executeUpdate(database.adaptorChannel(), theSQL);
>>>>
>>>> It works, but is there a better way or more correct way to create the
>>>> bytea attribute to insert.
>>>>
>>>>
>>>>
>>>> Ted
>>>>
>>>>
>>>> _______________________________________________
>>>> Do not post admin requests to the list. They will be ignored.
>>>> Webobjects-dev mailing list ([email protected]
>>>> <mailto:[email protected]>)
>>>> Help/Unsubscribe/Update your Subscription:
>>>> https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com
>>>> <https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com>
>>>>
>>>> This email sent to [email protected] <mailto:[email protected]>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list ([email protected])
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/webobjects-dev/rgurley%40smarthealth.com
>>
>> This email sent to [email protected]
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]