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

Escape character for /values #55

Closed
simonhunt8475 opened this issue Feb 28, 2024 · 2 comments
Closed

Escape character for /values #55

simonhunt8475 opened this issue Feb 28, 2024 · 2 comments

Comments

@simonhunt8475
Copy link

simonhunt8475 commented Feb 28, 2024

Would it be possible to have a an escape character for text values? I recently wanted to add data for financial years e.g. 22/23, 23/24 and 24/25, which didn't work. I've had similar issues adding text values with a quote e.g. O'tool.
Examples using '^' as an escape character:

  1. financial_year /values 22^/23, 23^/24, 24^/25

  2. surname vc60 /values O^'Hara, O^'Tool, O^'Meara

  3. start_date /values to_date(^'01-MAR-2024^',^'DD-MON-YYYY^'), to_date(^'01-APR-2025^',^'DD-MON-YYYY^')

@vadim-tropashko
Copy link
Member

vadim-tropashko commented Mar 5, 2024

I'm about to merge a fix where you'll have to use literals -- ordinary string literals or alternative ones. This would take care of the first two cases. The third case is handled with back quote literals, which are translated into SQL verbatim. Your example:

escape /insert 1
    financial_year /check '23/24', `'24/25'`
    surname vc60 /check 'O''Hara', q'{O'Tool}'  
    start_date /check  `to_date('01-APR-2025','DD-MON-YYYY')`

Output:

-- create tables

create table escape (
    id                number default on null to_number(sys_guid(), 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') 
                      constraint escape_id_pk primary key,
    financial_year    varchar2(4000 char) constraint escape_financial_year_ck
                      check (financial_year in ( '23/24','24/25')),
    surname           varchar2(60 char) constraint escape_surname_ck
                      check (surname in ( 'O''Hara',q'{O'Tool}')),
    start_date        date constraint escape_start_date_ck
                      check (start_date in ( to_date('01-APR-2025','DD-MON-YYYY')))
);

-- load data

insert into escape (
    id,
    financial_year,
    surname,
    start_date
) values (
    1,
    '24/25',
    q'{O'Tool}',
    to_date('01-APR-2025','DD-MON-YYYY')
);

neilfernandez added a commit that referenced this issue Mar 13, 2024
@neilfernandez
Copy link
Contributor

Resolved by #56

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

No branches or pull requests

3 participants