-
Notifications
You must be signed in to change notification settings - Fork 27
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
base: master
Are you sure you want to change the base?
Conversation
->isEqualTo(1) | ||
->integer($modelFk->countWhere($where)) | ||
->isEqualTo(1) | ||
->object($model->truncate(true, false)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping @chanmix51
There was a problem hiding this 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
#55