lapis icon indicating copy to clipboard operation
lapis copied to clipboard

Model\create! crashes

Open DarkWiiPlayer opened this issue 7 years ago • 3 comments
trafficstars

When you attempt to call create without arguments it crashes with the error [...]model.lua:169: bad argument #1 to 'pairs' (table expected, got nil)

I'm not sure if there's any use-cases for this, and I only found it myself because I was playing around with it, so maybe it's not worth fixing. Either way, it can be fixed with just adding a default parameter {} to the function.

DarkWiiPlayer avatar Mar 16 '18 15:03 DarkWiiPlayer

Okay, I take back the part about it being easy to solve. As it turns out, lapis doesn't handle empty value sets well and just creates a query like INSERT INTO "table" () VALUES () ... instead of INSERT INTO "table" DEFAULT VALUES ... as it should be.

DarkWiiPlayer avatar Mar 16 '18 15:03 DarkWiiPlayer

I think we should throw a more descriptive error when calling without {}

leafo avatar Mar 16 '18 18:03 leafo

It actually fails when calling with an empty table {} as well, so there isn't really a way to create a DEFAULT VALUES query :|

DarkWiiPlayer avatar Mar 17 '18 20:03 DarkWiiPlayer