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

add function truncate #92

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

stood
Copy link
Member

@stood stood commented Oct 25, 2020

#55

@stood stood marked this pull request as ready for review November 1, 2020 22:25
->isEqualTo(1)
->integer($modelFk->countWhere($where))
->isEqualTo(1)
->object($model->truncate(true, false))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not keen on myFunc(true, false) It would make more sense to me to have ->truncate("CASCADE AND MORE OPTIONS");
This IMHO let the developer with full control of future Pg extensions to the truncate command. The only issue I see is a security concern, it would imply to cut everything after a semicolon character to ensure a brain dead developer that passes truncate options from an external environment would still be safe.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option can be instead of "true, false" use some constant or bit like `truncate(PG_TRUNCATE_CASCADE | PG_TRUNCATE_RESTART)

If any extension is added, a simple define can be added.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with you for postgres developer, but for beginner developer, it's less easy. If you want to use an other syntax for truncate you could be to use ->query('TRUNCATE ....'). For me, the SQL is the best language but for the rest of the world is not a sexy language.
it would be a shame not to help those developpers, no? I thinks our job is to help the rest of the world to discover all the postgresql functionalities :)
Postgresql developer keeps control of his actions and queries, and the junior developer is not afraid of sql

But I'm ok to change the method signature because bool is not a good practice

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @chanmix51

Copy link
Member

@chanmix51 chanmix51 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change the truncate method signature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants