-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Model Alternative Key #431
Model Alternative Key #431
Conversation
To be able to specify an alternative key. For example; a country or currency alpha code, or a URL slug, etc… Added `$altKey` property, `findByKey($key)`, `findByIdKey($idKey)`, `saveByKey($key, $data)`, `saveByIdKey($idKey, $data)`, `updateByKey($key, $data)`, `updateByIdKey($idKey, $data)`, `deleteByKey($key)` and `deleteByIdKey($idKey)` public methods, and `findBy($byKeys, $value)`, `saveBy($byKeys, $data)`, `updateBy($byKeys, $key, $data)` and `deleteBy($byKeys, $key, bool $purge = false)` protected methods. Signed-off-by: Kristian Matthews <kristian.matthews@me.com>
Are there any This was the implementation I was thinking of, let me know your thoughts, and when agreed I'll add the documentation. |
See https://github.com/bcit-ci/CodeIgniter4/blob/develop/tests/system/Database/Live/ModelTest.php.
See https://github.com/bcit-ci/CodeIgniter4/tree/develop/tests#setup. |
Missed passing the key. Signed-off-by: Kristian Matthews <kristian.matthews@me.com>
@kenjis Thanks for pointing me to the model tests, I think we need some documentation on running database tests. |
@EpicKris Here's what we have currently: https://bcit-ci.github.io/CodeIgniter4/general/testing.html#testing-your-database Does that help? |
I'm not 100% on the implementation, honestly. A number of the items, like It's pretty late and I'm getting ready to crash, so I'll take a better look at this in the morning. |
@lonnieezell I agree with your solution, this was done quickly and obviously wasn't a good solution, I'll re-work this when I've got some time. Let me know if you have any other thoughts after taking another look in the morning. |
Added `withKey(string $key = null)` and `orWithKey(string $key = null)` methods. Signed-off-by: Kristian Matthews <kristian.matthews@me.com>
@lonnieezell Is this more in-line with what you had in mind? |
@EpicKris Conceptually, yes. I'd like to see tests on this, of course. Among those tests, please ensure you can have a primary key or alt key that is an array, since a number of database platforms support that. Oh yeah, and docs. :) Thanks. |
@lonnieezell Sorry for being quiet the last few months, things have been very busy, I'd like to get these tests and docs done and committed in the new few weeks though! |
# Conflicts: # system/Model.php
@EpicKris Glad to hear you're still with us! :) Hope the project went well, and I'd be interested to hear your experiences with CI4 since it sounded like you were actually building something on it? Shoot me an email with any good points/pain points. I'd love to hear them. And glad you'll be able to wrap this up. I was wondering which PRs were abandoned and which I would need to step in and finish. |
Signed-off-by: Kristian Matthews <kristian.matthews@me.com>
Updated job model, migrations, and seeds to include job `key`. Signed-off-by: Kristian Matthews <kristian.matthews@me.com>
Added `withAlt()` and `orWithAlt()` tests. Signed-off-by: Kristian Matthews <kristian.matthews@me.com>
Added `key` data. Signed-off-by: Kristian Matthews <kristian.matthews@me.com>
@lonnieezell The project went fairly well and is ongoing. I'll get an email across to you with my thoughts so far! Looks like Postgres tests are failing, I'm not able to test these myself, would someone be able to take a look for me? |
Is this PR still alive? |
@jim-parry This PR is still alive, although it looks like the Postgres tests are failing and I'm not able to test these myself and would need someone to be able to take a look for me. It also seems like I need to resolve some conflicts which I'll get on to as soon as possible. |
Is this still alive? |
I don't find this one a super-high priority item. Seeing as how it hasn't been touched 2 years, I'm going to say no one else does either. Closing. |
To be able to specify an alternative key. For example; a country or currency alpha code, or a URL slug, etc…
Added
$altKey
property,findByKey($key)
,findByIdKey($idKey)
,saveByKey($key, $data)
,saveByIdKey($idKey, $data)
,updateByKey($key, $data)
,updateByIdKey($idKey, $data)
,deleteByKey($key)
anddeleteByIdKey($idKey)
public methods, andfindBy($byKeys, $value)
,saveBy($byKeys, $data)
,updateBy($byKeys, $key, $data)
anddeleteBy($byKeys, $key, bool $purge = false)
protected methods.Issue: #428
Signed-off-by: Kristian Matthews kristian.matthews@me.com