Comments (8)
@eliasjpr As it stands with Granite, a fair amount of inflection assumptions are made in macros. I think relationships will need a major rewrite out of macro land before any real inflection library can be used. In the interim, I think fully configurable associations such as #103 is a workable solution.
from granite.
I agree, we should change this.
We should also look at adding a pluralize helper since adding an s
is not ideal. we should just add a couple rules like if the word ends with an s, ch, sh
then add es
. However, we shouldn't go overboard on this and add a custom dictionary of words. It should be a straightforward predictable algorithm.
from granite.
Regarding the snake case table names - I think that fix is easy:
Here: https://github.com/amberframework/granite-orm/blob/master/src/granite_orm/table.cr#L30
# Currently
{% name_space = @type.name.gsub(/::/, "_").downcase.id %}
# Change to
{% name_space = @type.name.gsub(/::/, "_").underscore.id %}
Regarding dealing with pluralization, I think leveraging an existing library is a good idea: https://github.com/mosop/string_inflection
from granite.
I’d second pulling in a proper inflector. There are undoubtedly times where pedantic inflection is mote confusing to the majority of people (eg Media, Data), but more often than not I appreciated the ease of Rails inflection. In other projects I’ve attempted to live with a cheaper solution and regretted it.
from granite.
There is a nice inflector created here https://github.com/luckyframework/lucky_inflector
from granite.
Also crecto has a nice query syntax 👉 https://github.com/Crecto/crecto#query-syntax Unrelated comment 😅
from granite.
@robacarp I agree with you on #103
from granite.
Opening a new ticket #129 regarding the inflector
from granite.
Related Issues (20)
- Is Granite still being maintained? HOT 1
- through in has_many doesn't work HOT 2
- Suggest add update_all and destroy_all methods
- Looking for maintainers HOT 2
- Doesn't work in Crystal 1.4.0 HOT 2
- `update` should only update changed fields on record HOT 4
- MySQL: After a certain amount of time/transactions connections freeze during spec tests HOT 4
- Feature: Automatic Connection Switching & Horizontal Sharding
- table.cr quotes things in a bad way HOT 1
- Feature: Do not require specifying connection if there is only 1 available. HOT 1
- Add support for multiple database connections & roles for PG via connection string
- UUID's as Primary Keys
- Import data maintaining timestamps HOT 3
- failed to start when use sqlite HOT 3
- Add `reload` method
- #to_yaml test fails on M1 Mac HOT 7
- Upgrade ameba shard to latest version HOT 2
- Can't subclass a subclass of Granite::Base? HOT 1
- Error creating record. HOT 1
- Missing `touch` callback on relationships
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from granite.