Browse Source

Add column names to database INSERTs

Neal Wilson 9 years ago
parent
commit
d352f33c3f

+ 4
- 4
config/Windows/newbatch.xml View File

@@ -324,13 +324,13 @@
324 324
 				checkQuery.exec("SELECT 1 FROM machine WHERE id = " + selectedRoasterID);
325 325
 				if(!checkQuery.next())
326 326
 				{
327
-					checkQuery.prepare("INSERT INTO machine VALUES(:id, :name)");
327
+					checkQuery.prepare("INSERT INTO machine (id, name) VALUES(:id, :name)");
328 328
 					checkQuery.bind(":id", selectedRoasterID);
329 329
 					checkQuery.bind(":name", selectedRoasterName);
330 330
 					checkQuery.exec();
331 331
 				}
332 332
 				checkQuery = checkQuery.invalidate();
333
-				var q = "INSERT INTO files VALUES(default, :name, 'profile', NULL, :data) RETURNING id";
333
+				var q = "INSERT INTO files (id, name, type, note, file) VALUES(default, :name, 'profile', NULL, :data) RETURNING id";
334 334
 				query = new QSqlQuery();
335 335
 				query.prepare(q);
336 336
 				query.bind(":name", timefield.text + " " + roasted.currentText);
@@ -340,7 +340,7 @@
340 340
 				var fileno = query.value(0);
341 341
 				var file = new QFile(batch.tempData);
342 342
 				file.remove();
343
-				var q2 = "INSERT INTO roasting_log VALUES(:time, ";
343
+				var q2 = "INSERT INTO roasting_log (time, unroasted_id, unroasted_quantity, unroasted_total_quantity, roasted_id, roasted_quantity, transaction_type, annotation, machine, duration, approval, humidity, barometric, indoor_air, outdoor_air, files) VALUES(:time, ";
344 344
 				q2 = q2 + table.columnArray(0, 32);
345 345
 				q2 = q2 + ", ";
346 346
 				for(var i = 0; table.data(i, 1, 0).value != ""; i++)
@@ -368,7 +368,7 @@
368 368
 				query2.exec();
369 369
                 query2 = query2.invalidate();
370 370
 				if(target.checked) {
371
-					var q3 = "INSERT INTO item_files VALUES(:time, :item, '{";
371
+					var q3 = "INSERT INTO item_files (time, item, files) VALUES(:time, :item, '{";
372 372
 					q3 = q3 + fileno;
373 373
 					q3 = q3 + "}')";
374 374
 					query.prepare(q3);

+ 1
- 1
config/Windows/newroaster.xml View File

@@ -17,7 +17,7 @@
17 17
 			var rnumber = findChildObject(this, 'id');
18 18
 			var nrwindow = this;
19 19
 			button.clicked.connect(function() {
20
-				var q = "INSERT INTO machine VALUES (";
20
+				var q = "INSERT INTO machine (id, name) VALUES (";
21 21
 				q = q + rnumber.text;
22 22
 				q = q + ", :name)";
23 23
 				query = new QSqlQuery();

+ 6
- 6
config/Windows/newsamplebatch.xml View File

@@ -252,7 +252,7 @@
252 252
 			var target = findChildObject(this, 'target');
253 253
 			submit.clicked.connect(function() {
254 254
 				query = new QSqlQuery();
255
-				query.prepare("INSERT INTO files VALUES(DEFAULT, :name, 'profile', NULL, :data) RETURNING id");
255
+				query.prepare("INSERT INTO files (id, name, type, note, file) VALUES(DEFAULT, :name, 'profile', NULL, :data) RETURNING id");
256 256
 				query.bind(":name", timefield.text + " " + name.text + " " + profileName.currentText);
257 257
 				query.bindFileData(":data", batch.tempData);
258 258
 				query.exec();
@@ -262,7 +262,7 @@
262 262
 				file.remove();
263 263
 				if(target.checked)
264 264
 				{
265
-					query.prepare("INSERT INTO sample_roast_profiles VALUES(:time, :name, :file)");
265
+					query.prepare("INSERT INTO sample_roast_profiles (time, profile_name, file) VALUES(:time, :name, :file)");
266 266
 					query.bind(":time", timefield.text);
267 267
 					query.bind(":name", profileName.currentText);
268 268
 					query.bind(":file", Number(fileno));
@@ -293,14 +293,14 @@
293 293
 					}
294 294
 					else
295 295
 					{
296
-						query.prepare("INSERT INTO item_attributes VALUES(DEFAULT, :name) RETURNING id");
296
+						query.prepare("INSERT INTO item_attributes (id, name) VALUES(DEFAULT, :name) RETURNING id");
297 297
 						query.bind(":name", attname);
298 298
 						query.exec();
299 299
 						query.next();
300 300
 						attributes.setData(i, 0, query.value(0), 32);
301 301
 					}
302 302
 				}
303
-				query.prepare("INSERT INTO coffee_sample_items VALUES(DEFAULT, :name, NULL, 'lb', 0, 'Coffee: Green Sample', :arrival, :vendor, :attrids, :attrvals, NULL) RETURNING id");
303
+				query.prepare("INSERT INTO coffee_sample_items (id, name, reference, unit, quantity, category, arrival, vendor, attribute_ids, attribute_values) VALUES(DEFAULT, :name, NULL, 'lb', 0, 'Coffee: Green Sample', :arrival, :vendor, :attrids, :attrvals) RETURNING id");
304 304
 				query.bind(":name", name.text);
305 305
 				query.bind(":arrival", arrival.date);
306 306
 				query.bind(":vendor", vendor.text);
@@ -309,12 +309,12 @@
309 309
 				query.exec();
310 310
 				query.next();
311 311
 				var greenId = query.value(0);
312
-				query.prepare("INSERT INTO items VALUES(DEFAULT, :name, NULL, 'lb', 0, 'Coffee: Roasted Sample') RETURNING id");
312
+				query.prepare("INSERT INTO items (id, name, reference, unit, quantity, category) VALUES(DEFAULT, :name, NULL, 'lb', 0, 'Coffee: Roasted Sample') RETURNING id");
313 313
 				query.bind(":name", name.text + " " + profileName.currentText);
314 314
 				query.exec();
315 315
 				query.next();
316 316
 				var roastedId = query.value(0);
317
-				query.prepare("INSERT INTO roasting_log VALUES(:time, :unroastedids, NULL, :green, :roastedid, :roasted, 'SAMPLEROAST', :note, :machine, :duration, TRUE, NULL, NULL, NULL, NULL, :files)");
317
+				query.prepare("INSERT INTO roasting_log (time, unroasted_id, unroasted_quantity, unroasted_total_quantity, roasted_id, roasted_quantity, transaction_type, annotation, machine, duration, approval, humidity, barometric, indoor_air, outdoor_air, files) VALUES(:time, :unroastedids, NULL, :green, :roastedid, :roasted, 'SAMPLEROAST', :note, :machine, :duration, TRUE, NULL, NULL, NULL, NULL, :files)");
318 318
 				query.bind(":time", timefield.text);
319 319
 				query.bind(":unroastedids", "{" + greenId + "}");
320 320
 				query.bind(":green", convertToPounds(parseFloat(green.text), GunitBox.currentText));

+ 1
- 1
config/Windows/optime.xml View File

@@ -63,7 +63,7 @@
63 63
 			});
64 64
 			submitbutton.clicked.connect(function() {
65 65
 				query = new QSqlQuery();
66
-				var q = "INSERT INTO operational_time VALUES (:machine, :start, :stop, :duration)";
66
+				var q = "INSERT INTO operational_time (machine, start_time, end_time, duration) VALUES (:machine, :start, :stop, :duration)";
67 67
 				query.prepare(q);
68 68
 				query.bind(":machine", machine.currentData());
69 69
 				query.bind(":start", startline.text);

+ 1
- 1
config/Windows/profilehistory.xml View File

@@ -51,7 +51,7 @@
51 51
 		var currentProfileID;
52 52
 		setCurrent.clicked.connect(function() {
53 53
 			var query = new QSqlQuery();
54
-			query.prepare("INSERT INTO item_files VALUES('now', :coffee, :profile)");
54
+			query.prepare("INSERT INTO item_files (time, item, files) VALUES('now', :coffee, :profile)");
55 55
 			query.bind(":coffee", coffeelist.currentData());
56 56
 			query.bind(":profile", "{" + currentProfileID + "}");
57 57
 			query.exec();

+ 8
- 8
config/Windows/purchase.xml View File

@@ -203,7 +203,7 @@
203 203
             var dateField = findChildObject(this, 'date');
204 204
             submitButton.clicked.connect(function() {
205 205
                 var query = new QSqlQuery;
206
-                var q = "INSERT INTO invoices VALUES (default, :invoice, :vendor, :date) RETURNING id";
206
+                var q = "INSERT INTO invoices (id, invoice, vendor, time) VALUES (default, :invoice, :vendor, :date) RETURNING id";
207 207
                 query.prepare(q);
208 208
                 query.bind(":invoice", invoiceField.text);
209 209
                 query.bind(":vendor", vendorField.currentText);
@@ -246,11 +246,11 @@
246 246
                     }
247 247
                     if(decafSelection.checked)
248 248
                     {
249
-                        q = "INSERT INTO decaf_coffees VALUES (default, :name, :reference, :unit, 0, 'Coffee: Unroasted', :origin, :region, :producer, :grade, :milling, :drying, :decafMethod) RETURNING id";
249
+                        q = "INSERT INTO decaf_coffees (id, name, reference, unit, quantity, category, origin, region, producer, grade, milling, drying, decaf_method) VALUES (default, :name, :reference, :unit, 0, 'Coffee: Unroasted', :origin, :region, :producer, :grade, :milling, :drying, :decafMethod) RETURNING id";
250 250
                     }
251 251
                     else
252 252
                     {
253
-                        q = "INSERT INTO coffees VALUES (default, :name, :reference, :unit, 0, 'Coffee: Unroasted', :origin, :region, :producer, :grade, :milling, :drying) RETURNING id";
253
+                        q = "INSERT INTO coffees (id, name, reference, unit, quantity, category, origin, region, producer, grade, milling, drying) VALUES (default, :name, :reference, :unit, 0, 'Coffee: Unroasted', :origin, :region, :producer, :grade, :milling, :drying) RETURNING id";
254 254
                     }
255 255
                     query.prepare(q);
256 256
                     query.bind(":name", nameEntry.currentText);
@@ -317,7 +317,7 @@
317 317
                     query.exec();
318 318
                     query.next();
319 319
                     var item_id = query.value(0);
320
-                    q = "INSERT INTO purchase VALUES(:time, :item, :quantity, :cost, :vendor)";
320
+                    q = "INSERT INTO purchase (time, item, quantity, cost, vendor) VALUES(:time, :item, :quantity, :cost, :vendor)";
321 321
                     query.prepare(q);
322 322
                     query.bind(":time", dateField.date);
323 323
                     query.bind(":item", item_id);
@@ -333,14 +333,14 @@
333 333
                     }
334 334
                     query.bind(":vendor", vendorField.currentText);
335 335
                     query.exec();
336
-                    q = "INSERT INTO lb_bag_conversion VALUES(:item, :conversion)";
336
+                    q = "INSERT INTO lb_bag_conversion (item, conversion) VALUES(:item, :conversion)";
337 337
                     query.prepare(q);
338 338
                     query.bind(":item", item_id);
339 339
                     var bagsEntry = findChildObject(current, 'bags');
340 340
                     var conversion = convertToPounds(parseFloat(quantityEntry.text), unitEntry.currentText) / Number(bagsEntry.text);
341 341
                     query.bind(":conversion", conversion);
342 342
                     query.exec();
343
-                    q = "INSERT INTO invoice_items VALUES(:id, 'PURCHASE', :item, :description, :cost)";
343
+                    q = "INSERT INTO invoice_items (invoice_id, record_type, item_id, description, cost) VALUES(:id, 'PURCHASE', :item, :description, :cost)";
344 344
                     query.prepare(q);
345 345
                     query.bind(":id", invoiceNumber);
346 346
                     query.bind(":item", item_id);
@@ -356,7 +356,7 @@
356 356
                     query.exec();
357 357
                     var certifications = findChildObject(current, 'certdisplay');
358 358
                     var certlist = certifications.text.split(",");
359
-                    q = "INSERT INTO certifications VALUES (:item, :certification)";
359
+                    q = "INSERT INTO certifications (item, certification) VALUES (:item, :certification)";
360 360
                     query.prepare(q);
361 361
                     query.bind(":item", item_id);
362 362
                     for(var j = 0; j < certlist.length; j++)
@@ -366,7 +366,7 @@
366 366
                     }
367 367
                 }
368 368
                 var descriptionArray = sqlToArray(feesTable.columnArray(0, 0));
369
-                var q = "INSERT INTO invoice_items VALUES (:id, 'FEE', NULL, :description, :cost)";
369
+                var q = "INSERT INTO invoice_items (invoice_id, record_type, item_id, description, cost) VALUES (:id, 'FEE', NULL, :description, :cost)";
370 370
                 query.prepare(q);
371 371
                 query.bind(":id", invoiceNumber);
372 372
                 if(descriptionArray.length > 0)

+ 3
- 3
config/Windows/roastmanager.xml View File

@@ -46,7 +46,7 @@
46 46
                 window.displayStatus("Item removed.");
47 47
             });
48 48
             restoreButton.clicked.connect(function() {
49
-                var q = "INSERT INTO current_items VALUES (:id)";
49
+                var q = "INSERT INTO current_items (item) VALUES (:id)";
50 50
                 query = new QSqlQuery();
51 51
                 query.prepare(q);
52 52
                 query.bind(":id", drop2.currentData());
@@ -59,14 +59,14 @@
59 59
                 window.displayStatus("Item restored.");
60 60
             });
61 61
             newItemButton.clicked.connect(function() {
62
-                var q = "INSERT INTO items VALUES (default, :name, NULL, 'lb', 0, 'Coffee: Roasted') RETURNING id";
62
+                var q = "INSERT INTO items (id, name, reference, unit, quantity, category) VALUES (default, :name, NULL, 'lb', 0, 'Coffee: Roasted') RETURNING id";
63 63
                 query = new QSqlQuery();
64 64
                 query.prepare(q);
65 65
                 query.bind(":name", itemname.text);
66 66
                 query.exec();
67 67
                 query.next();
68 68
                 var i = query.value(0);
69
-                q = "INSERT INTO current_items VALUES(:id)";
69
+                q = "INSERT INTO current_items (item) VALUES(:id)";
70 70
                 query.prepare(q);
71 71
                 query.bind(":id", i);
72 72
                 query.exec();

Loading…
Cancel
Save