mirror of https://github.com/AMT-Cheif/drift.git
Pending changes exported from your codespace
This commit is contained in:
parent
91781fa20f
commit
2098e76dd5
|
@ -13,12 +13,17 @@ String dataClassNameForClassName(String tableName) {
|
||||||
// they're storing (users, products, ...). We try to find the singular word
|
// they're storing (users, products, ...). We try to find the singular word
|
||||||
// from the table name.
|
// from the table name.
|
||||||
|
|
||||||
// todo we might want to implement some edge cases according to
|
|
||||||
// https://en.wikipedia.org/wiki/English_plurals
|
|
||||||
|
|
||||||
if (tableName.endsWith('s')) {
|
if (tableName.endsWith('s')) {
|
||||||
|
if (tableName.endsWith('ss') || tableName.endsWith('us') || tableName.endsWith('sses')) {
|
||||||
|
return tableName;
|
||||||
|
} else if (tableName.endsWith('ies')) {
|
||||||
|
return tableName.substring(0, tableName.length - 3) + 'y';
|
||||||
|
} else {
|
||||||
return tableName.substring(0, tableName.length - 1);
|
return tableName.substring(0, tableName.length - 1);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return tableName;
|
||||||
|
}
|
||||||
|
|
||||||
// Default behavior if the table name is not a valid plural.
|
// Default behavior if the table name is not a valid plural.
|
||||||
return '${tableName}Data';
|
return '${tableName}Data';
|
||||||
|
|
Loading…
Reference in New Issue