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

Sylius states #926

Merged
merged 4 commits into from
Jan 29, 2014
Merged

Sylius states #926

merged 4 commits into from
Jan 29, 2014

Conversation

winzou
Copy link
Contributor

@winzou winzou commented Jan 28, 2014

Ref: #915
States set according to: https://github.com/Sylius/Sylius/wiki/Status

@pjedrzejewski
Copy link
Member

👍

@elliot
Copy link
Contributor

elliot commented Jan 28, 2014

For the sake of consistency, should we make the OrderInterface::STATE_* constants strings as well - instead of integers?

We are already doing it for PaymentInterface, ShipmentInterface, InventoryUnitInterface, and OrderShippingStates.

@winzou
Copy link
Contributor Author

winzou commented Jan 29, 2014

@elliot I would do the opposite, use integer everywhere? Think of database size once we have lots of inventory units! @Sylius, opinion?

@kayue
Copy link
Contributor

kayue commented Jan 29, 2014

Sylius is using a mix of integer and string, look at the order table...

Personally I vote for string and developer friendliness. It is 2014 we don't have to care about storage anymore.

@winzou
Copy link
Contributor Author

winzou commented Jan 29, 2014

My concern is not about storage but about execution time for database queries. We very often filter or sort by state, wouldn't it be much faster to do it on integers than strings?
Database queries are already not optimized at all by using Doctrine, if we can do a bit on our side, it's good to take I think.

@kayue
Copy link
Contributor

kayue commented Jan 29, 2014

I cannot deny there will be improvement by using integer but the improvement here is so little and not enough to convince me to give away developer happiness.

@jjanvier
Copy link
Contributor

I vote for strings. Not sure such "optimizations" are relevant.

@winzou
Copy link
Contributor Author

winzou commented Jan 29, 2014

OK, so 2 vs 1 for now, fair enough. I need more votes for the democracy to win 👯

@antonioperic
Copy link
Contributor

Vote for strings

@stloyd
Copy link
Contributor

stloyd commented Jan 29, 2014

I'm always all for integers, as a developer I don't look at value of constant, as it doesn't bother me what's there, the name of that constant should be clear & that's enough.

When I have OrderInterface::STATE_CART = 1 (example), I can easily sort it, I can go with bitwise values if needed etc., when it's OrderInterface::STATE_CART = 'cart', it's not so easy IMO anymore. Additionally there is no point for string as a developer MUST NOT use integer/string values when want to mention the constant value, he MUST call the constant, so in this case: OrderInterface::STATE_CART.

Sorry but I can't understand what's "developer happiness" in this case? You parse your database values manually?! Sorry but I don't get it...

While I'm not totally against the strings, I don't see any pros of using it TBH.

I would vote to leave it as it is, and create new "RFC" about choosing strings or integers for constant values.

@kayue
Copy link
Contributor

kayue commented Jan 29, 2014

My use case is I generate report directly from database, or open database table for debugging purpose. Using string allow me to understand the result without further processing.

@winzou
Copy link
Contributor Author

winzou commented Jan 29, 2014

But since when we design a database for report & debugging purpose?

@jjanvier
Copy link
Contributor

When you have a bug in production. This bug can't be reproduced on dev. You have no relevant log. So, no other choice than see what's on database.

@pjedrzejewski
Copy link
Member

I tend to agree with @jjanvier and @kayue about the strings... However, this should be discussed. Let's open a separate issue.

@winzou
Copy link
Contributor Author

winzou commented Jan 29, 2014

Storing 1000 times the same string in the same column... My old SQL skills are crying!
Guys, have you really forgotten all database-related common sense? Just for a bit of comfort when debugging your database?

@winzou
Copy link
Contributor Author

winzou commented Jan 29, 2014

Anyway this PR is green and good to merge :)

@pjedrzejewski
Copy link
Member

@winzou This is how I did this before as well, but the main reason was the space. Now it's not that relevant. On the other hand, argument by @stloyd is convincing me, because developer always MUST use the contants and not the raw values, so it does not matter. Yeah, it's easier to browse the database manually without remembering which INT represents which status...

pjedrzejewski pushed a commit that referenced this pull request Jan 29, 2014
@pjedrzejewski pjedrzejewski merged commit 3332ef9 into Sylius:master Jan 29, 2014
@pjedrzejewski
Copy link
Member

This travis false-positives are driving me insane. I want to see green!

@pjedrzejewski
Copy link
Member

Thanks Alexandre! 👍

@winzou winzou deleted the statuses branch January 29, 2014 10:59
@jjanvier
Copy link
Contributor

@winzou, IMO this is really a detail. Load a big page on Sylius and look at the number of requests. This makes my old SQL skills crying.

And to clarify. I'm totally OK to use integers for constants everywhere. It's no big deal. But if I have the choice between string and int, my first choice goes to int.

Awesome PR anyway :)

@antonioperic
Copy link
Contributor

I agree with @jjanvier - this is 21th century sites are bigger and bigger everyday. we need to do some denormalization. Every new features brings some new queries and if we can do something without JOINS then i think that is good solutions.

I dont say that @stloyd doesn't have right when he is talking about constants but we need to think about performance also

@stloyd
Copy link
Contributor

stloyd commented Jan 29, 2014

@pjedrzejewski Additionally I can create a PR that will add "comment" into database field that describes the status int => string.

<field type="string" name="paymentState" column="payment_state" />
<!-- to this -->
<field type="integer" name="paymentState" column="payment_state">
    <options>
        <option name="comment" value="1 = new\n2 = pending\n3 = processing" />
    </options>
</field>

For sure it's supported by the MySQL, not sure about other platforms, but it's not a case IMO =)

btw. Who will create that RFC issue? 💃

@elliot
Copy link
Contributor

elliot commented Jan 30, 2014

The best of both worlds would be to use ENUM's (displayed as strings, stored as uints) - but Doctrine doesn't support those out of the box unless we define our own data type. Do we want to go down that path?

pamil pushed a commit to pamil/Sylius that referenced this pull request May 7, 2019
pamil pushed a commit to pamil/Sylius that referenced this pull request May 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants