Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command/Query Separation for ROM::Commands #606

Open
Krule opened this issue Oct 24, 2017 · 7 comments
Open

Command/Query Separation for ROM::Commands #606

Krule opened this issue Oct 24, 2017 · 7 comments
Assignees
Milestone

Comments

@Krule
Copy link
Collaborator

Krule commented Oct 24, 2017

According to CQS principle:

Every method should either be a command that performs an action, or a query that returns data to the caller, but not both.

With that in mind I would like to see a refactor of the following with at least an option for a commands not to perform additional database query in order to return the updated state (especially since we usually know what state is expected to be a result of the execution in advance):

@abrthel
Copy link

abrthel commented Nov 2, 2017

@solnic you were saying that you regret adding result: :many or result: :one but maybe a custom command set with result: :void could trigger this behavior?

@solnic
Copy link
Member

solnic commented Nov 2, 2017

@abrthel oh we definitely do not want to add another option for result :) I think all that's needed, is splitting methods in a way that we don't get results back in the same method. Once it's separated, we can conditionally get results using a separate method, and it could be configured.

@abrthel
Copy link

abrthel commented Nov 2, 2017

@solnic how would you envision configuring if results are returned or not?

I imagine, you'd want to be able to do something like:
relation.command(:create, option_name: :value)

but what would you call the option?

@solnic
Copy link
Member

solnic commented Nov 17, 2017

So, been thinking about this and realized it's something we want to do in rom 5.0 / rom-sql 3.0.

@solnic solnic changed the title Proposal: Command/Query Separation for ROM::SQL::Commands Command/Query Separation for ROM::SQL::Commands Nov 17, 2017
@solnic solnic self-assigned this Nov 17, 2017
@paddor
Copy link

paddor commented May 19, 2020

@solnic Did something to fix this behavior make it into rom 5.0 / rom-sql 3.0? I'd like to avoid an additional SELECT query after a :create command.

@solnic
Copy link
Member

solnic commented May 20, 2020

@paddor no, but it's very likely it'll be addressed in rom 6.0.0 and rom-sql 4.0

@solnic solnic transferred this issue from rom-rb/rom-sql Jun 25, 2020
@solnic solnic added this to the 6.0.0 milestone Jun 25, 2020
@solnic
Copy link
Member

solnic commented Jun 25, 2020

I allowed myself to move this issue to the rom repository, because it's going to be a core feature and it will Just Work™ in rom-sql. This is now scheduled for 6.0.0 release.

@solnic solnic changed the title Command/Query Separation for ROM::SQL::Commands Command/Query Separation for ROM::Commands Jun 25, 2020
@solnic solnic moved this to Backlog in rom-rb 6.0 May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

4 participants