Capture meta endpoint refactor#168
Conversation
ccf88e9 to
4aadefe
Compare
|
otherwise looks ok |
b127696 to
fcbe2e3
Compare
|
Rebased, no changes required. |
fcbe2e3 to
8a36d15
Compare
|
Reworked according to the new Api specification document. |
|
please rebase |
5e8e09d to
f29022a
Compare
|
Endpoint and unit test renewals. Ready for review. |
|
|
||
| -- remove all capture meta from capture if key is null | ||
| IF (meta_key) IS NULL THEN | ||
| DELETE cm.*, cmk.* |
| WHERE cm.capture_id = capture_id; | ||
| ELSE | ||
| -- delete from capture with the given key | ||
| DELETE cm.*, cmk.* |
| AND cm.meta_value = capture_meta_value | ||
| AND cmk.meta_key_name = capture_meta_key) = 0) THEN | ||
| -- insert new record | ||
| INSERT INTO cfe_18.capture_meta_key(meta_key_name) VALUES (capture_meta_key); |
There was a problem hiding this comment.
insert ignore or handle duplicate key before this
|
|
||
| // Creates the request | ||
| HttpPut captureMetaRequest = new HttpPut("http://localhost:" + port + "/capture/meta/"); | ||
| HttpPut captureMetaRequest = new HttpPut("http://localhost:" + port + "/v2/captures/definitions/1/metadata"); |
There was a problem hiding this comment.
should this be on the CaptureMetaControllerTest.java
There was a problem hiding this comment.
will be dealt with #248 by removing the test case altogether as it is deemed obsolete to test fetch by key in Capture Definition.
125dabb to
4ed2bd3
Compare
|
Changes applied and rebased |
|
Added unique constraint on capture meta key since it did not exist before. Was producing multiple key entries and always matching the latest ID instead of one ID per key. |
| END IF; | ||
|
|
||
|
|
||
| -- check if capture already has key value |
There was a problem hiding this comment.
is it possible to insert multiple different key-value pairs with the same key? if not then this should either return error that value is already set if it does not match the inserted one or update but we do not support updating so the error path is more appropriate.
There was a problem hiding this comment.
if exact same row DOES NOT exist then insert. If any of the 3 variables change then insert is always possible and will be inserted if record is new. Every relation here is N:N.
To be fair the comment is a bit misleading since we are only avoiding the constraint error from happening here and moving away from inserting the record if same record already exists.
Fixes issue #73
More info on PR #155