My Code:
DB::table('books')->join('brands', 'books.user_id', '=', 'brands.user_id')->get();
Got this Error:
"SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: bigint = character varying\nLINE 1: ...* from \"users\" inner join \"books\" on \"users\".\"id\" = \"books\"....\n ^\nHINT: No operator matches the given name and argument types. You might need to add explicit type casts
Bumped into this while debugging a query from the ORM and have no idea why it happens. Asking mostly out of curiosity. In PostgreSQL 12.5 the following occurs:
-- All good:
select ('$[*] ? (#.live_at <= 2020-11-18)')::jsonpath
jsonpath |
---------------------------------------|
$[*]?(#."live_at" <= (2020 - 11) - 18) |
-- But then:
select ('$[*] ? (#.live_at <= 2020-05-18)')::jsonpath
SQL Error [42601]: ERROR: syntax error, unexpected IDENT_P at end of jsonpath input
Position: 9
SQL Error [42601]: ERROR: syntax error, unexpected IDENT_P at end of jsonpath input
Position: 9
SQL Error [42601]: ERROR: syntax error, unexpected IDENT_P at end of jsonpath input
Position: 9
SQL Error [42601]: ERROR: syntax error, unexpected IDENT_P at end of jsonpath input
Position: 9
ERROR: syntax error, unexpected IDENT_P at end of jsonpath input
Position: 9
ERROR: syntax error, unexpected IDENT_P at end of jsonpath input
Position: 9
I've a suspicion that this is related to octal representation, but node seems to eat 2020-05-18 just fine. What gives?
I need to fix few lines in Jira configuration in PostgreSQL. Unfortunatelly it uses dot notation in columns and I cannot fine a way how to escape it.
select * from "cwd_directory_attribute";
directory_id | attribute_name | attribute_value
1 | user_encryption_method | atlassian-security
10000 | ldap.user.filter | (objectclass=person)
No escaping:
psql:fix_directory.sql:1: ERROR: column "ldap" of relation "cwd_directory_attribute" does not exist
LINE 1: update cwd_directory_attribute set ldap.basedn='ou=sandbox,d...
Single quote:
psql:fix_directory.sql:1: ERROR: syntax error at or near "'ldap.basedn'"
LINE 1: update cwd_directory_attribute set 'ldap.basedn'='ou=sandbox...
Double quote:
psql:fix_directory.sql:1: ERROR: column "ldap.basedn" of relation "cwd_directory_attribute" does not exist
LINE 1: update cwd_directory_attribute set "ldap.basedn" ='ou=sandb...
Square bracket:
psql:fix_directory.sql:1: ERROR: syntax error at or near "["
LINE 1: update cwd_directory_attribute set [ldap.basedn] ='ou=sandb...
E.g.
update cwd_directory_attribute set "ldap.basedn" ='ou=sandbox,dc=eu' where directory_id=10100;
I found answers that double quotes shall work but they do not. I could modify the columns manually in some SQL editor, but I want to set up a script:
psql -f fix_directory.sql jiradb7
What is the proper escaping for columns in UPDATE procedure?
Update:
select "ldap.secure" from "cwd_directory_attribute";
ERROR: syntax error at or near "select"
LINE 2: select "ldap.secure" from "cwd_directory_attribute";
You are confusing column values and column names.
Your table has a column named attribute_name which contains the value 'ldap.user.filter' (and supposedly 'ldap.basedn' in a different row).
So what you want is:
update cwd_directory_attribute
set attribute_value = 'ou=sandbox,dc=eu'
where directory_id = 10100
and attribute_name = 'ldap.basedn';
I have been struggling to assign the query result to a temp variable in PostgreSQL and I just can't get it to work. Can anyone guide please?
I tried with the both the below queries and I get the error shown below. I then tried with temp table. But it still fails during the assignment to the temp variable.
set var.ITEM_ID =(select t.item_id from api_item t inner join api_identifier i on i.item_id=t.item_id where i.value='99999');
set var.ITEM_ID = select t.item_id from api_item t inner join api_identifier i on i.item_id=t.item_id where i.value='99999';
The first statement throws the error :-
[2020-03-03 08:10:50] [42601] ERROR: syntax error at or near "("
[2020-03-03 08:10:50] Position: 23
Second one throws the below error:-
[2020-03-03 08:10:55] [42601] ERROR: syntax error at or near "select"
[2020-03-03 08:10:55] Position: 24
Moving from heroku to dokku / digital ocean, I've used pg_dump to copy the database into a file 'latest.dump' and using pg_restore to my local pg db and it worked properly. But when I try to run the dokku postegresql:restore command, it runs and I receive 'database restored' but there are many errors and none of the data is actually restored. Any suggestions for how to troubleshoot / what is causing the errors?
root#domain:~# dokku postgresql:restore db_name < dokku/db/latest.dump
ERROR: syntax error at or near "PGDMP"
LINE 1: PGDMP
id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: version character varying(255) NOT NULL
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: _time, early_l...
^
ERROR: syntax error at or near "_price"
LINE 1: _price, delivery_counter, credit_card, yrd_per) FROM stdin;
^
ERROR: syntax error at or near "ADD"
LINE 1: ADD CONSTRAINT adjustments_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT clients_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT contacts_tables_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT deliveries_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT devices_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT drivers_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT groups_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT invoices_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT jobs_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT locations_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT materials_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT messages_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT mixes_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT orders_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT payments_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT plants_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT products_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT statements_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT tags_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT trucks_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT users_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT workdays_pkey PRIMARY KEY (id);
^
invalid command \
invalid command \
invalid command \�/x$Ր�8X~`�O`�����*a
�ЛU[2u^����ar���m��kU�"���!���c,Llel��ˀ��u�ʚb[
invalid command \�n
invalid command \$�I�m�
ɤ�HK��
invalid command \�}�b����7�6�]D�x�����|��l�D�Y}�P��A�T�װLJ��.{�ۇ�{c�bܤ��
invalid command \2��h[�/!I��${�7�#lHhLD���dÄG#�P�rL���qtkU����Iܩ&$�i�I��=0!�
invalid command \��`.���y���,�{0B�z�f3�^��?q�
invalid command \W���WIJ����lQ�
invalid command \r�9�S܀�fk�
invalid command \螀ܠ��T��g���eXx{j��8����x�Xt6�
invalid command \~zʘ�Z���OiƘbl}#p�E��.�;א}{8I��b�]��Rf�1��0
invalid command \q�6|P
��o��j���I���V
^��S
invalid command \��(��D����a����B(�ϓ]n�~Љ��������W����
invalid command \$�a��s8�5g��:�=#�!^�L6�0mjO;3��/�Ei7��)�Xp�K�
invalid command \�����q�P�ZF��
ERROR: syntax error at or near ""
LINE 1: ��kη�>6�x�
E�����U����d�]T���&
��_E>p��k��In�~�...
^
invalid command \x�6�`YIk
invalid command \�Q��8�
<¼��njWڡ��
invalid command \դ�n�|��p�ҍ���gve�d�]�{�/Ó+�Q�.�NQ�s��z)`SI.��v�8�U��[ͮi�Z�������FU
invalid command \�M�>=���7�;��4�!y25�J�������E=��(�LS֜{�S�I�3;
invalid command \ʑ<�0b<��Jm��y�]��9�B���V(��#��?���{�m�]AVv3嘫�f�Q�X=���
invalid command \l�I�W.
invalid command \��i���Tc��^���
invalid command \�刄��+�u�
invalid command \([����&DrLL�NC�l���E�J��uR��c�HQ�e*e�e8�V?R/�y���O�S��.+c��7E�V5�K��ɵC'��
invalid command \�
invalid command \'�Ε]���[ޮ���h�J/RV=�'�v�7m�z�-�,���v]�X�����Z%�5��P�jYi�.�N,���[δ���v��1`���n�օ��h
invalid command \�Wb���'�B-62y��
invalid command \�������sl�Q�
ERROR: syntax error at or near "Lnܚ"
LINE 1: Lnܚ��H�f�2U�Q���"��C��4(+6a�0EF?�*:�'=��^�^i� �T�)�...
^
invalid command \#i�ě��(������g���ժ�`Q˅&�O{�F������%��u�(GEMW��0�����G���}1�8�u��rF�V4�Y4:�'�h���ݟ�M�8�Q�
invalid command \'g�7�Zo����#i���R��jY��u*%��E���ց��s��M�'�#�d��<9�?���&�Rd�v�TTj3B=>��]Y6DsT�hǃ���=w�D�M47��!2�B�%�f��)S�ʽJr���8;��].x^�Vv�ɸ7����'R��BG5��rMt�F��&���{�)�B�����_~����f��*���ۻLJ���wo�m�{|����.�����������w��e9�&g�Ə�lNQ�<|�6˙��u��f��p��40�1g]�0ő�թ��-+�M��r����+���e�+�i���s݂�����b��y�ݾy>���S��m�2nUǨ���x[v�vخ�yec�h3[-}����N�s��:^�p���%�ʑ�I�ŸO������5Ģ!Bj�h��
ERROR: syntax error at or near "2"
LINE 1: 2^͗i��u� ���U�9zD>����(���q�ϫCw��O��6Q[D��...
^
invalid command \��Q%�,~�
invalid command \S��C�
�
ERROR: syntax error at or near "�3��"
LINE 1: �3��� ��0� V�[�� �Bz2K�W�1�X�:��|E{2� D���+sQ�...
^
ERROR: syntax error at or near "˭�y��"
LINE 1: ˭�y��
���4�:��Rz�g+�����ɲ�U+1�V
�"�
^
invalid command \Y8��t��.
invalid command \�;�K
ERROR: syntax error at or near "Y��"
LINE 1: Y��]�hI?w}8�U��C�K��`2c���/��]*NTG+�����
&ai��-w...
^
invalid command \���:vH*a7���g�7uZ����ƴ5j8���
invalid command 0��M���-U0�9�+���b,R�
ERROR: syntax error at or near "��9�"
LINE 1: ��9�
�UD6q�)�LѴ��L�I�U��t�g��t�;xVM9����&��o����OO...
^
invalid command \ܯո�i$0��2�i�
invalid command \�0�2�$�XM�Y�r�i�7�k�e����������~z}�"�&��H(�
invalid command \Z�3��F�6t�
invalid command \O�k�i�|�bJ�+�$ٝHO�j_�ƲF���S�R���Z�
invalid command \sȗ�������Zu�/�>ddz��Mr���G��Y���wi�����p��[����Cw�#�&�K���$j�w�|wa�����
invalid command \�d���j���
invalid command \[9ד���sPFo���c�S��>���hG>GOߥ��;��۞Z��`�6�Aa
invalid command \���g<Y��I#��FR��V�
invalid command \w��枎�S�%����=uR��7
invalid command \�k'�#��li��P4��F�I��^E��߷��7
invalid command \��onC�!�CX�;1����s�yFdy2�G���'S�82��
invalid command \��V���Bh{�
invalid command \��s���`
invalid command \�N&h�:31$�Mul+��k��<.�b�Z���g.�YUn1^�u�"𠒑GƇ�#Ʈ�.�>ߙ�h
invalid command \�xIrK�2
ERROR: syntax error at or near "�"
LINE 1: ��I��}*X�L����_���%��~8gt�ȃ�l�BZ,˹��s]��d�����h�e�a/
^
invalid command \k�
Nj��#��#���79M��L�|�o�6Lᘪ��[&�[(��*�
ERROR: syntax error at or near "�"
LINE 1: �
^
-----> db_name database restored
I believe a similar problem happened to me when trying to complete a similar task. You need to use a .sql file when uploading the database to your new stack. By default, Heroku gives you a .dump file. What worked for me was copying the database to my local development pg db using the .dump file and then using that to generate a .sql file which I pushed to my new app.
This worked for me:
pg_restore -O latest.dump | dokku postgresql:restore <db_name>
found here: https://github.com/Kloadut/dokku-pg-plugin/issues/52