no-mistakes-postgres-engine 0.109.129

PostgreSQL embedded SQL extraction, schema catalog, and replay-safety analysis for no-mistakes
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use no_mistakes_ts_facts::syntax_helpers::unwrap_ts_wrappers;
use oxc_ast::ast::Expression;

/// A computed write is harmless only when its key is a known other property.
pub(super) fn may_write_query(key: &Expression<'_>, names: &[String]) -> bool {
    !matches!(
        unwrap_ts_wrappers(key),
        Expression::StringLiteral(literal) if !names.iter().any(|name| name == no_mistakes_ts_facts::ast::js_literal(literal).as_ref())
    )
}

pub(super) fn may_write_boundary(key: &Expression<'_>) -> bool {
    !matches!(unwrap_ts_wrappers(key), Expression::StringLiteral(literal)
        if !matches!(no_mistakes_ts_facts::ast::js_literal(literal).as_ref(), "commit" | "rollback"))
}