Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic table name generation #355

Merged
merged 7 commits into from
May 23, 2018
Merged

Automatic table name generation #355

merged 7 commits into from
May 23, 2018

Conversation

groue
Copy link
Owner

@groue groue commented May 22, 2018

This PR brings a default implementation for the TableRecord.databaseTableName property:

struct Place: TableRecord { }
Place.databaseTableName // "place"

This default name follows the GRDB3 database schema recommendation: generated table name are singular, camel-cased, and look like a Swift identifier:

  • Place: place
  • Country: country
  • PostalAddress: postalAddress
  • HTTPRequest: httpRequest
  • TOEFL: toefl

Due to a limitation of the Swift compiler, Record subclasses must keep on explicitly overriding databaseTableName:

class Place: Record {
    override var databaseTableName: String {
        return "place"
    }
}

@groue groue added this to the GRDB 3.0 milestone May 22, 2018
@groue groue mentioned this pull request May 22, 2018
29 tasks
@groue groue merged commit 5ccf878 into GRDB3 May 23, 2018
@groue groue deleted the GRDB3-AutomaticTableName branch May 23, 2018 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant