Having a convo on my team about naming tables in S...
# squarelibraries
c
Having a convo on my team about naming tables in SQLDelight. We want to name things plural (like a "Persons" table) but then all of the autogenerated stuff gives us Persons.name instead of Person.name. Incredibly minor detail, i know. But most of stackoverflow reccs to name tables as plural, but the auto generated names being plural are a little misleading. Am I missing something? Or should I just cave and call my table Person (even though its for multiple persons)
v
I decided to break SQL naming conventions in favour of having my Kotlin conventions. So Table "persons" will be called DbPerson for me.
K 1
g
I'm going with PersonTable on my project, also used PersonEntity on another project 🤷
l
We're definitely using singular names for our tables as well for the same reason. Breaking that convention felt strange at first but we haven't second guessed it since. Also, since we almost always have a data class named the same thing as the table, but slightly different than the one generated in SQLDelight, we add a "Record" suffix to the table name, (e.g.
PersonRecord
) so that it's easy to distinguish the two. Then it's easy to recognize
PersonRecord
as the autogenerated one from the database and
Person
as our actual domain object. We like "Record" a little better than "Table" for this because it's more clear that it represents a single row, rather than something that represents the table itself.
1
👍 1
s
Yes, I also use
PersonDb
for the same reason that it should not be mixed up with
Person
domain objects. You convinced me that "Record" sounds like an even better name.
🍻 1