Git Product home page Git Product logo

Comments (8)

robacarp avatar robacarp commented on September 18, 2024 2

@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.

drujensen avatar drujensen commented on September 18, 2024

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.

marksiemers avatar marksiemers commented on September 18, 2024

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.

robacarp avatar robacarp commented on September 18, 2024

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.

eliasjpr avatar eliasjpr commented on September 18, 2024

There is a nice inflector created here https://github.com/luckyframework/lucky_inflector

from granite.

faustinoaq avatar faustinoaq commented on September 18, 2024

Also crecto has a nice query syntax 👉 https://github.com/Crecto/crecto#query-syntax Unrelated comment 😅

from granite.

eliasjpr avatar eliasjpr commented on September 18, 2024

@robacarp I agree with you on #103

from granite.

drujensen avatar drujensen commented on September 18, 2024

Opening a new ticket #129 regarding the inflector

from granite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.