no-mistakes-postgres-engine 0.109.130

PostgreSQL embedded SQL extraction, schema catalog, and replay-safety analysis for no-mistakes
Documentation
use super::member_query_text;
use oxc_ast::ast::{Expression, Statement};
use std::path::Path;

#[test]
fn member_query_text_rejects_missing_spread_computed_and_duplicate_properties() {
    let cases = [
        ("client.query();", false),
        ("client.query({ ...opts, text: 'SELECT 1' });", false),
        ("client.query({ [key]: 'SELECT 1' });", false),
        ("client.query({ text() {}, other: 1 });", false),
        (
            "client.query({ text: 'SELECT 1', text: 'SELECT 2', other: 1 });",
            false,
        ),
        ("client.query({ other: 1, text: 'SELECT 1' });", true),
    ];
    for (source, expected) in cases {
        no_mistakes_ts_facts::ast::with_program(Path::new("query.ts"), source, |program, _| {
            let Some(Statement::ExpressionStatement(stmt)) = program.body.first() else {
                panic!("expected expression statement");
            };
            let Expression::CallExpression(call) = &stmt.expression else {
                panic!("expected call expression");
            };
            assert_eq!(member_query_text(call).is_some(), expected, "{source}");
        })
        .unwrap();
    }
}