NubeBuster
NubeBuster
Explore posts from servers
PPrisma
Created by NubeBuster on 5/28/2024 in #help-and-questions
Queryraw condition joining
I added a playground for you to explore and experiment with this issue https://github.com/Nubebuster/prisma-raw
10 replies
PPrisma
Created by NubeBuster on 5/28/2024 in #help-and-questions
Queryraw condition joining
Bump
10 replies
PPrisma
Created by NubeBuster on 5/28/2024 in #help-and-questions
Queryraw condition joining
Bump
10 replies
PPrisma
Created by NubeBuster on 5/28/2024 in #help-and-questions
Queryraw condition joining
Bump
10 replies
PPrisma
Created by NubeBuster on 5/28/2024 in #help-and-questions
Queryraw condition joining
Is this impossible?
10 replies
PPrisma
Created by NubeBuster on 5/28/2024 in #help-and-questions
Queryraw condition joining
Bump
10 replies
PPrisma
Created by NubeBuster on 5/28/2024 in #help-and-questions
Queryraw condition joining
What does "Expected 4 strings to have 3 values" even mean...?
10 replies
PPrisma
Created by NubeBuster on 5/28/2024 in #help-and-questions
Queryraw condition joining
const conditions = [];
const params = [];

// Add bookingCount condition if it exists
if (bookingCount !== undefined) {
conditions.push(`bookingCount > ?`);
params.push(`${bookingCount}`);
}

// Add zipCodeLike conditions if they exist
if (Array.isArray(zipCodeLike) && zipCodeLike.length > 0) {
const zipConditions = zipCodeLike
.map(() => `recentZIPCode LIKE ?`)
.join(" OR ");
conditions.push(`(${zipConditions})`);
params.push(...zipCodeLike);
}

// Combine all conditions into a single WHERE clause
let whereClause = "";
if (conditions.length > 0) {
whereClause = `SELECT * FROM #TempResults WHERE ${conditions.join(" AND ")}`;
}
console.log("TTT", whereClause, params);

const query = Prisma.sql([whereClause, ...params]);
const conditions = [];
const params = [];

// Add bookingCount condition if it exists
if (bookingCount !== undefined) {
conditions.push(`bookingCount > ?`);
params.push(`${bookingCount}`);
}

// Add zipCodeLike conditions if they exist
if (Array.isArray(zipCodeLike) && zipCodeLike.length > 0) {
const zipConditions = zipCodeLike
.map(() => `recentZIPCode LIKE ?`)
.join(" OR ");
conditions.push(`(${zipConditions})`);
params.push(...zipCodeLike);
}

// Combine all conditions into a single WHERE clause
let whereClause = "";
if (conditions.length > 0) {
whereClause = `SELECT * FROM #TempResults WHERE ${conditions.join(" AND ")}`;
}
console.log("TTT", whereClause, params);

const query = Prisma.sql([whereClause, ...params]);
TTT SELECT * FROM #TempResults WHERE bookingCount > ? AND (recentZIPCode LIKE ? OR recentZIPCode LIKE ?) [ '2', '22%', '21%' ] ⨯ TypeError: Expected 4 strings to have 3 values
10 replies