Skip to content

Commit a2455de

Browse files
authored
fix: add repo column support to database_build.js (#302)
* fix: add repo column support to database_build.js Port the repo field fix from database_build.py (PR #289) to the new Node.js database build script. PDS JSON sources now include a repo field; this adds a repo VARCHAR(500) column to all tables and inserts the value (or null) during import. Fixes #241 Signed-off-by: vmuralictr <vmurali.ctr@gmail.com> * fix: deduplicate comma-separated repo values during import Some PDS source files contain repo fields with the same value repeated many times (e.g. 47x), exceeding the VARCHAR(500) column limit. Dedupe the comma-separated values using a Set before inserting, so only unique repo names are stored. See: linux-on-ibm-z/PDS#127 Signed-off-by: vmuralictr <vmurali.ctr@gmail.com> --------- Signed-off-by: vmuralictr <vmurali.ctr@gmail.com>
1 parent ddc4ece commit a2455de

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

bin/database_build.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ async function createTable(connection, tblname) {
3232
packageName VARCHAR(100) NOT NULL,
3333
version VARCHAR(500) NOT NULL,
3434
description VARCHAR(500),
35+
repo VARCHAR(500),
3536
osName VARCHAR(100) NOT NULL,
3637
PRIMARY KEY (pkgId)
3738
)`;
@@ -53,6 +54,7 @@ async function jsonToSql(connection, table, file, osName) {
5354
item.packageName,
5455
item.version,
5556
item.description || null,
57+
item.repo ? [...new Set(item.repo.split(','))].join(',') : null,
5658
osName
5759
]);
5860

@@ -61,7 +63,7 @@ async function jsonToSql(connection, table, file, osName) {
6163
return;
6264
}
6365

64-
const query = `INSERT INTO \`${table}\` (packageName, version, description, osName) VALUES ?`;
66+
const query = `INSERT INTO \`${table}\` (packageName, version, description, repo, osName) VALUES ?`;
6567
await connection.query(query, [finalData]);
6668
console.log(`${table} : Entries filled`);
6769
}

0 commit comments

Comments
 (0)