SeaQL/sea-query

Escape string \z meaningless for postgres

Opened this issue · 0 comments

Description

The default string escaper uses \z to escape 0x1a ("substitute character"). However, this is not a valid escape sequence in postgresql. The list of valid escape sequences can be found here.

Steps to Reproduce

#[test]
fn test_substitute_char() {
    let ch: SimpleExpr = '\u{1a}'.into();
    let query = Query::select()
        .expr(ch)
        .to_owned();
    // Just one possible escape (other possibilities include e.g. \u001A, etc.)
    assert_eq!(query.to_string(PostgresQueryBuilder), r#"SELECT E'\x1A'"#);
}

Expected Behavior

The output is a valid escape of \x1a.

Actual Behavior

Sea query attempts to escape using \z, but this is not a valid escape character.

Reproduces How Often

Deterministic

Versions

Sea query 0.30.1

Additional Information