Closed fwgreen closed 6 years ago
Hey @fwgreen, to specify the table name you would write:
extension Availability: Model {
static var tableName: String = "public.availability"
}
Currently we do not support the ability to change the column names. We could look to add this feature!
Hey @fwgreen , I have realised that for the custom column names you can just use CodingKeys, like so:
extension Availability: Model {
enum ColumnKeys: String, CodingKey {
case id, starting, ending, overtime
case onShift = "on_shift"
}
}
@EnriqueL8 This is a potentially elegant solution, that at the moment doesn't work: I only have one table without a snake-cased column name and it's the only one that Kuery-ORM can retrieve. Everything else triggers an empty 500 error which isn't caught by the logger, but instead is only seen in my REST client.
PS: While tableName
got rid of the original SQL error on the database server, there is still the underlying issue of the magical "s" being appended to some names.
Hey @fwgreen, the magical "s" is appended by default to the table names to remove is you can specify the tableName
String as I mentioned above. If you think that the magical "s" should not be appended the we could think to add a toggle?
For the column names, I made a mistake instead of ColumnKeys
it is had to be CodingKeys
Like so,
enum CodingKeys: String, CodingKey {
case id, starting, ending, overtime
case onShift = "on_shift"
}
Let me know if you need anything else
Thanks for putting me on the right path!
Hello, i am quite new user to this project however, i believe an s behind every table just randomly need to be fixed, as this is a bug in the code. Right ?
Clearly its fine that struct name = table name but not struct name = table name + s . Especially working with existing tables like me this gives a whole lot of a mess.
The here presented solution is simply a work around on an issue that still seems to exist.
My example: I try to read out from a table: wp_amelia_providers_to_daysoff ... and i can simply not do it. unless i probably apply the work around which i will now try to do.
But i would still looking forward that the magical s bug is fixed. By the way i am using now: Swift Kuery: 3.0.1 Swift ORM: 0.6.0 SwiftKueryMySQL 2.0.2
@Beautylivery The problem is this is a deliberate design choice and not a bug. The architects have assumed that all users are English speakers and all English nouns are pluralized by adding an "S". Feel free to open a new issue.
I have an existing table called
availability
on PostgreSQLHere's my model
This is the error message from the database server
Oddly, it does not do this with all entity names. It would be great if one could specify table and column names, JPA style:
let tableName = "whatever_name"
is completely ignored.