Pending changes exported from your codespace

This commit is contained in:
Abass Sesay 2023-10-22 20:48:29 +00:00
parent 91781fa20f
commit 2098e76dd5
1 changed files with 9 additions and 4 deletions

View File

@ -13,11 +13,16 @@ String dataClassNameForClassName(String tableName) {
// they're storing (users, products, ...). We try to find the singular word
// 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')) {
return tableName.substring(0, tableName.length - 1);
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);
}
} else {
return tableName;
}
// Default behavior if the table name is not a valid plural.