From c4453c7ef575eac76bdc4e342f01d83606ba31ba Mon Sep 17 00:00:00 2001 From: Nicolas Paschoud <nicolas.paschoud@etu.hesge.ch> Date: Wed, 18 Dec 2019 18:48:21 +0100 Subject: [PATCH] Editing the size of the paths field in the DB --- projet/db/hyperdrive.sql | 7 ++++--- projet/sql-request.js | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/projet/db/hyperdrive.sql b/projet/db/hyperdrive.sql index 7e5e895..e0a18a4 100644 --- a/projet/db/hyperdrive.sql +++ b/projet/db/hyperdrive.sql @@ -11,9 +11,9 @@ CREATE TABLE IF NOT EXISTS Users ( ); CREATE TABLE IF NOT EXISTS Paths ( - paths varchar(50) NOT NULL, + paths varchar(400) NOT NULL, login varchar(60) NOT NULL, - parent varchar(50), + parent varchar(400), PRIMARY KEY (paths), FOREIGN KEY (login) REFERENCES Users(login), FOREIGN KEY (parent) REFERENCES Paths(paths) @@ -22,9 +22,10 @@ CREATE TABLE IF NOT EXISTS Paths ( CREATE TABLE IF NOT EXISTS Files ( file_id varchar(100) NOT NULL, file_name varchar(50) NOT NULL, - paths varchar(50) NOT NULL, + paths varchar(400) NOT NULL, lat FLOAT, lng FLOAT, + addedon INT, PRIMARY KEY (file_id), FOREIGN KEY (paths) REFERENCES Paths(paths) ); diff --git a/projet/sql-request.js b/projet/sql-request.js index 74f9e23..f09db8b 100644 --- a/projet/sql-request.js +++ b/projet/sql-request.js @@ -57,6 +57,7 @@ function insertUser(login, passwd, callback){ * @param {string} parent Parent of the new folder */ function addPath(path, login, parent, callback){ + if (parent) parent = "'" + parent + "'"; let q = `INSERT INTO Paths VALUES ('${path}', '${login}', ${parent});`; con.query(q, function(err, res) { if (err) { -- GitLab