cds-pg icon indicating copy to clipboard operation
cds-pg copied to clipboard

use snaky case for table name / view name

Open clockrun opened this issue 2 years ago • 4 comments

convert table and column name to snaky case

clockrun avatar Oct 21 '22 16:10 clockrun

Hi Colleagues, by default, table name / view name / column name in PostgresQL is case sensitive. So the normal way is to either use double quote to quote name so that name in SQL express can be directly mapped to name in database. Or alternatively, we use snaky case, so that every letter is in lower case and every word is split by underscore. The current status of this project, will simply removing all underscore in table name and replace dot with underscore between different object. E.g. definition in cds: PurchaseOrder.DeliveryAddress will be traslate into database object: purchaseorder_deliveryaddress

After translation, the name become unreadable. Ideally, we should get purchase_order_delivery_address or purchase_order__delivery_address

clockrun avatar Oct 21 '22 16:10 clockrun

perhaps we can use similar way like Spring. https://www.baeldung.com/hibernate-field-naming-spring-boot

Predefine some naming strategy and let developer decide which one to use. In this case, we will need capire to support it.

clockrun avatar Oct 21 '22 16:10 clockrun

Hi @clockrun,

thank you for your suggestion. Have you tried running the tests localy before an after your changes? As you can see the tests are failing in CI.

KR, Gregor

gregorwolf avatar Oct 22 '22 08:10 gregorwolf

Hi Gregor, Yes, that's something we need to discuss. SInce the naming convention has changed, all those unit test need to be rewrite. Let's confirm the design and then update test case.

Regards, Clockrun

clockrun avatar Oct 23 '22 15:10 clockrun

thanks for being onboard 🙏 - but cds-pg sailed has sailed into the official SAP harbor and become a bigger boat ⛵️😄 https://github.com/cap-js/cds-dbs/tree/main/postgres Please continue contributing there!

vobu avatar Jul 14 '23 09:07 vobu