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

Postgres over-escaping ? #715

Open
rolivares opened this issue Apr 5, 2024 · 0 comments
Open

Postgres over-escaping ? #715

rolivares opened this issue Apr 5, 2024 · 0 comments

Comments

@rolivares
Copy link

rolivares commented Apr 5, 2024

In order to get this sentence using WhereRaw:

SELECT * 
FROM "condition_tests" 
WHERE (
  "field_varchar_nullable" IS NOT NULL 
  AND unaccent(TRIM(regexp_replace(field_varchar_nullable, E'[\\n\\r]+', '', 'g' )))  ilike '%' || unaccent('le dijo')
)

I've used this string as raw sentence:

var sentence = @"unaccent(TRIM(regexp_replace(field_varchar_nullable, E'[\\n\\r]+', '', 'g' )))  ilike '%' || unaccent('le dijo')";
var query = new Query("condition_tests").WhereNotNull("field_varchar_nullable").WhereRaw(sentence);

I'm getting this expression (note the replace chars near E '"\n\r"+', '', 'g') )

SELECT
  *
FROM
  "condition_tests"
WHERE
  "field_varchar_nullable" IS NOT NULL
  AND unaccent(
    TRIM(
      regexp_replace(field_varchar_nullable, E '"\\n\\r"+', '', 'g')
    )
  ) ilike '%' || unaccent('le dijo')

If you compare results using MSSql and postgresql factory are different on chars "[" and "]".

How can I escape or acomplish the statement: E'[\n\r]+'

Thanks

UPDATE: note the space after "E" on expression => E '"\n\r"+', '', 'g') this is addded qhen symbol "[" is replaced
When I've try to escape the symbols with "" that space continues appearing in consequence SQL does not work

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

1 participant