ValentinFunk / LibK

Library for fast gmod addon development
MIT License
51 stars 21 forks source link

LibK not respecting field order in model #36

Closed kaiaverkvist closed 2 years ago

kaiaverkvist commented 3 years ago

Is this something we can get added support for?

ValentinFunk commented 3 years ago

Could you help me understand the issue a bit? What do you mean by field order?

kaiaverkvist commented 3 years ago

If I define a model like this: bilde

Then field order isn't preserved, causing weird UX inside of for instance phpmyadmin bilde

ValentinFunk commented 3 years ago

That makes sense, I think it's because for key-value tables lua does not preserve the order, so we would need to use something like an array instead

fields: {
  { name = "variables", type = "table" },
  { name = "created", type = "createdTime" }
}

I don't think there's an easy solution here without changing the API a lot and making it incompatible with previous versions 😢 The current API is a bit less typing and a easier to parse quickly with your eyes, too.

If there are no issues with field order for actual interaction with the db through code and it's only for coding, I believe there should be a way for you to reorder them in phpMyAdmin. It's definitely annoying but you should only have to do it once