mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-21 05:58:10 +02:00
chore: inspect v_ca_fournisseur view structure
This commit is contained in:
1 parent
072479b30f
commit
67b0c8c74f
1 file changed
+23
-18
@@ -4,34 +4,39 @@ import { sql } from "drizzle-orm";
|
|||||||
|
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
try {
|
try {
|
||||||
// 1. Colonnes réelles de fouadr1
|
// 1. Colonnes de v_ca_fournisseur
|
||||||
const cols = await db.execute(sql`
|
const vCols = await db.execute(sql`
|
||||||
SELECT column_name, data_type
|
SELECT column_name, data_type
|
||||||
FROM information_schema.columns
|
FROM information_schema.columns
|
||||||
WHERE table_name = 'fouadr1'
|
WHERE table_name = 'v_ca_fournisseur'
|
||||||
ORDER BY ordinal_position
|
ORDER BY ordinal_position
|
||||||
`);
|
`);
|
||||||
|
|
||||||
// 2. Toutes les tables contenant "fou"
|
// 2. Sample de v_ca_fournisseur
|
||||||
const tables = await db.execute(sql`
|
const vSample = await db.execute(sql`
|
||||||
SELECT table_name
|
SELECT * FROM v_ca_fournisseur LIMIT 10
|
||||||
FROM information_schema.tables
|
|
||||||
WHERE table_schema = 'public'
|
|
||||||
AND table_name ILIKE '%fou%'
|
|
||||||
ORDER BY table_name
|
|
||||||
`);
|
`);
|
||||||
|
|
||||||
// 3. Sample de fouadr1 (5 lignes brutes)
|
// 3. D005 dans v_ca_fournisseur
|
||||||
const sample = await db.execute(sql`SELECT * FROM fouadr1 LIMIT 5`);
|
const vD005 = await db.execute(sql`
|
||||||
|
SELECT * FROM v_ca_fournisseur
|
||||||
|
WHERE code = 'D005' OR codefou = 'D005'
|
||||||
|
OR raisonsociale ILIKE '%depot%' OR raisonsociale ILIKE '%bazar%'
|
||||||
|
LIMIT 10
|
||||||
|
`);
|
||||||
|
|
||||||
// 4. Sample de fouadr1 pour code D005
|
// 4. Définition SQL de la vue
|
||||||
const d005 = await db.execute(sql`SELECT * FROM fouadr1 WHERE code = 'D005' LIMIT 10`);
|
const vDef = await db.execute(sql`
|
||||||
|
SELECT definition
|
||||||
|
FROM pg_views
|
||||||
|
WHERE viewname = 'v_ca_fournisseur'
|
||||||
|
`);
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
fouadr1_columns: cols.rows,
|
v_ca_fournisseur_columns: vCols.rows,
|
||||||
tables_with_fou: tables.rows,
|
v_ca_fournisseur_sample: vSample.rows,
|
||||||
fouadr1_sample: sample.rows,
|
v_ca_fournisseur_d005: vD005.rows,
|
||||||
fouadr1_d005: d005.rows,
|
view_definition: vDef.rows,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return NextResponse.json({ error: String(e) }, { status: 500 });
|
return NextResponse.json({ error: String(e) }, { status: 500 });
|
||||||
|
|||||||
Reference in new issue
Block a user