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

Configurable table prefix #69

Closed
wants to merge 3 commits into from

Conversation

kPshi
Copy link

@kPshi kPshi commented Aug 9, 2018

Allows to set a TableMapper (similar to the FieldMapper) field in DB which then may return different table names even within the same process for different DB configurations.
The GetTableName function has been renamed in order to match the naming of DefaultFieldMapFunc and in order to prevent hard to find bugs later on.

Usages of GetTableName should ideally rewritten to use

DB.TableMapper

For setting a prefix per instance of DB use

db := NewFromDB(myPlainDB, "mysql")
db.TableMapper = func(a interface{}) string {
    return "myprefix_" + DefaultTableMapFunc(a)
}

@coveralls
Copy link

coveralls commented Aug 9, 2018

Coverage Status

Coverage increased (+0.02%) to 89.188% when pulling 33fd39f on kPshi:configurable_table_prefix into b7add2e on go-ozzo:master.

@qiangxue qiangxue closed this in 6442c82 Jan 7, 2020
@qiangxue
Copy link
Member

qiangxue commented Jan 7, 2020

Thank you for your contribution! I've merged your code manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants