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

support unicode literal strings prefixed with U& #512

Open
lovasoa opened this issue Jul 27, 2024 Discussed in #511 · 1 comment
Open

support unicode literal strings prefixed with U& #512

lovasoa opened this issue Jul 27, 2024 Discussed in #511 · 1 comment
Labels
bug Something isn't working

Comments

@lovasoa
Copy link
Collaborator

lovasoa commented Jul 27, 2024

Discussed in #511

Originally posted by lozdown July 27, 2024
I have a simple Postgresql database application for managing attendance records of club members at events, with table for members, table for events and a many-to-many join table linking events and members.

This query works correctly in pgadmin4.

with 
attendances as (
 select distinct
 	em."members_Contact ID" contactid,
 	(bool_or((CASE WHEN e.eventdate ='2024-01-17' THEN true END))) "2024-01-17"
 from events_members em inner join events e on em.events_id=e.id 
 group by em."members_Contact ID"
)
select m."First Name",m."Last Name",
	case when "2024-01-17"  then U&'\2713'  else 'x' end as "2024-01-17" 

	from members m left join attendances a on m."Contact ID"=a.contactid ;

Giving example result table
"F" "A" "✓"
"A" "A" "✓"
"C" "A" "x"
"J" "F" "x"

(nb "✓" indicates attended, "x" indicates absent)

However the same query used in SQLPage throws an error associated with the escaped unicode string U&'\2173'

Error in query number 1:

Failed to execute SQL statement:
WITH attendances AS (SELECT DISTINCT em."members_Contact ID" AS contactid, (bool_or((CASE WHEN e.eventdate = '2024-01-17' THEN true END))) AS "2024-01-17" FROM events_members AS em JOIN events AS e ON em.events_id = e.id GROUP BY em."members_Contact ID") SELECT m."First Name", m."Last Name", CASE WHEN "2024-01-17" THEN U & '\2713' ELSE 'x' END AS "2024-01-17" FROM members AS m LEFT JOIN attendances AS a ON m."Contact ID" = a.contactid;
⬆️
line 1, character 322

Backtrace

error returned from database: column "u" does not exist

column "u" does not exist

The SQLPage definition is

select
'table' as 'component', true as 'small',
TRUE as search
;

with
attendances as (
select distinct
em."members_Contact ID" contactid,
(bool_or((CASE WHEN e.eventdate ='2024-01-17' THEN true END))) "2024-01-17"
from events_members em inner join events e on em.events_id=e.id
group by em."members_Contact ID"
)
select m."First Name",m."Last Name",
case when "2024-01-17" then &'\2713' else 'x' end as "2024-01-17"

from members m left join attendances a on m."Contact ID"=a.contactid
;

If I change the U&'2713' to '2713' the query executes (although clearly does not display tick mark that I want)

@lovasoa
Copy link
Collaborator Author

lovasoa commented Jul 27, 2024

Reported upstream in apache/datafusion-sqlparser-rs#1354

@lovasoa lovasoa added the bug Something isn't working label Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant