bwsamern-ohne_standortplaner/backend/test_null_query.js

40 lines
1.2 KiB
JavaScript

const { Client } = require('pg');
async function testQuery() {
const client = new Client({
host: '87.106.21.21',
port: 5432,
user: 'enwelo_admin',
password: 'WX1t1cgP1qK09',
database: 'enwelo'
});
try {
await client.connect();
const nachname = '';
const vorname = 'Anja';
console.log(`Querying for GNA='${nachname}' AND VNA='${vorname}'`);
const res1 = await client.query(
`SELECT "FSK" FROM geodaten.flaecheneigentuemer_alkis WHERE "GNA" = $1 AND "VNA" = $2`,
[nachname, vorname]
);
console.log(`Found: ${res1.rowCount} rows.`);
console.log(`Querying for (GNA=$1 OR (GNA IS NULL AND $1='')) AND VNA=$2`);
const res2 = await client.query(
`SELECT "FSK" FROM geodaten.flaecheneigentuemer_alkis
WHERE ("GNA" = $1 OR ("GNA" IS NULL AND $1 = ''))
AND ("VNA" = $2 OR ("VNA" IS NULL AND $2 = ''))`,
[nachname, vorname]
);
console.log(`Found: ${res2.rowCount} rows.`);
} catch (e) {
console.error("Error:", e);
} finally {
await client.end();
}
}
testQuery();