-
Notifications
You must be signed in to change notification settings - Fork 137
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
Implement backend data field filter for H2 & Postgresql (similar to MongoDB) #3516
Implement backend data field filter for H2 & Postgresql (similar to MongoDB) #3516
Conversation
- field/value filter - value filter of type bool/number/string - enable filter wildcards for string value - add documentation Also-by: Matthias Feurer [email protected] Signed-off-by: g.dimitropoulos <[email protected]>
- run same unittests for all JDBC implementations Also-by: Matthias Feurer [email protected] Signed-off-by: g.dimitropoulos <[email protected]>
Sonatype Lift is retiringSonatype Lift will be retiring on Sep 12, 2023, with its analysis stopping on Aug 12, 2023. We understand that this news may come as a disappointment, and Sonatype is committed to helping you transition off it seamlessly. If you’d like to retain your data, please export your issues from the web console. |
@@ -60,7 +60,7 @@ The tenants in the registry can be managed using the Device Registry Management | |||
The JDBC based registry implementation does not support the following features: | |||
|
|||
* Tenants can be retrieved using the [search tenants]({{< relref "/api/management#tenants/searchTenants" >}}) | |||
operation defined by the Device Registry Management API, but the *filterJson* and *sortJson* query parameters are | |||
operation defined by the Device Registry Management API, but the *sortJson* query parameters are |
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.
... query parameter is (currently) being ignored.
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.
Done
@@ -1687,10 +1687,11 @@ components: | |||
filterJson: | |||
name: filterJson | |||
in: query | |||
description: | | |||
description: | |
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.
can you remove the trailing whitespaces?
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.
Done
REPLACE(data, '"') LIKE CONCAT('%%', :field, ':', REPLACE(:value, '"')) | ||
ORDER BY device_id ASC | ||
LIMIT :page_size | ||
OFFSET :page_offset |
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.
can you please add an EOL?
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.
Done
jsonb_extract_path(data,'ext')->>:field LIKE CAST(:value as varchar) | ||
ORDER BY device_id ASC | ||
LIMIT :page_size | ||
OFFSET :page_offset |
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.
can you please add an EOL?
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.
Done
FROM %s | ||
WHERE |
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.
can you remove the trailing whitespace?
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.
Done
* @param key The key of the device. | ||
* @param span The span to contribute to. |
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.
can you please remove the tabs here and in the other locations?
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.
Done
* @param field the field of filter expression | ||
* @param value the value of the filter expression |
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.
please start with a capital letter and end with a period (.
)
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.
Done
// check if we got back a result, if not this will abort early | ||
.compose(result -> extractVersionForUpdate(result, resourceVersion)) | ||
|
||
// take the version and start processing on | ||
.compose(version -> Future.succeededFuture() | ||
|
||
.compose(x -> { | ||
final Promise<CredentialsDto> result = Promise.promise(); | ||
final var updatedCredentialsDto = CredentialsDto.forUpdate( |
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.
is anything being changed here or did you only change the indentation?
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.
only the indentation
* @param tenantId The tenantId to search devices. | ||
* @param pageSize The page size. | ||
* @param pageOffset The page offset. | ||
* @param filters The list of filters. |
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.
FMPOV we should document that only the first item in the list will be considered.
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 change the "The list of filters." to "The list of filters (currently only the first value of the list is used)."
import java.nio.file.Path; | ||
|
||
|
||
class JdbcPostgresDeviceManagementSearchDevicesTest extends JdbcBasedDeviceManagementSearchDevicesTest { |
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.
what is this class needed for?
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.
This class changes the DEFAULT_DATABASE_TYPE from H2 to POSTGRESQL and runs all the tests from JdbcBasedDeviceManagementSearchDevicesTest. We need this to run the tests against both types of JDBC DBs.
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.
The type of database being used when running the tests is determined by the AbstractJdbcRegistryTest.databaseType
system property. The tests are being run for both H2 and Postgresql by means of the two configurations of the Maven Surefire plugin in services/device-registry-jdbc/pom.xml
. FMPOV there is no need for this class.
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 remove the class
Also-by: Matthias Feurer [email protected] Signed-off-by: g.dimitropoulos <[email protected]>
Also-by: Matthias Feurer [email protected] Signed-off-by: g.dimitropoulos <[email protected]>
Also-by: Matthias Feurer [email protected] Signed-off-by: g.dimitropoulos <[email protected]>
Also-by: Matthias Feurer [email protected] Signed-off-by: g.dimitropoulos <[email protected]>
Also-by: Matthias Feurer [email protected] Signed-off-by: g.dimitropoulos <[email protected]>
protected static DatabaseType DEFAULT_DATABASE_TYPE = DatabaseType.H2; | ||
protected static DatabaseType DATABASE_TYPE = DatabaseType.valueOf(System.getProperty(AbstractJdbcRegistryTest.class.getSimpleName() |
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.
looks like these changes can be reverted as well now, can't they?
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.
yes, i change it back to private final
* @param key The key of the device to create. | ||
* @param device The device data. | ||
* @param tenant The configuration of the tenant that the device belongs to. | ||
* @param globalDevicesPerTenantLimit The globally defined maximum number of devices per tenant. A value | ||
* <= 0 will be interpreted as no limit being defined. | ||
* @param spanContext The span to contribute to. | ||
* @param spanContext The span to contribute to. |
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.
can you please remove this indentation?
* @param key The key of the device to update. | ||
* @param statement The statement to use for the update. | ||
* @param jsonValue The value to set. | ||
* @param resourceVersion The optional resource version. | ||
* @param nextVersion The new version to set. | ||
* @param span The span to contribute to. | ||
* @param nextVersion The new version to set. | ||
* @param span The span to contribute to. |
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.
remove tabs
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.
Done
* @param key The key of the device to update. | ||
* @param device The device data to store. | ||
* @param resourceVersion The optional resource version. | ||
* @param spanContext The span to contribute to. | ||
* @param spanContext The span to contribute to. |
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.
remove tabs
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.
Done
@@ -477,7 +547,7 @@ public Future<Versioned<Void>> updateDevice( | |||
* If there is exactly one row, it will read the device registration information from the column | |||
* {@code data} and optionally current resource version from the column {@code version}. | |||
* | |||
* @param key The key of the device to read. | |||
* @param key The key of the device to read. |
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.
remove tabs
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.
Done
* @param key The key of the device to delete. | ||
* @param resourceVersion An optional resource version. | ||
* @param spanContext The span to contribute to. | ||
* @param spanContext The span to contribute to. |
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.
remove tabs
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.
Done
* @param tenantId The tenant to count devices for. | ||
* @param spanContext The span to contribute to. | ||
* @param countStatement The count statement to use. | ||
* @param field The field of filter expression. | ||
* @param value The value of the filter expression. |
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.
remove tabs
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.
Done
* @param key The key of the device to update. | ||
* @param credentials The credentials to set. | ||
* @param resourceVersion The optional resource version to update. | ||
* @param spanContext The span to contribute to. | ||
* @param spanContext The span to contribute to. |
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.
remove tabs
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.
Done
/** | ||
* Get all credentials for a device. | ||
* <p> | ||
* This gets the credentials of a device. If the device cannot be found, the | ||
* result must be empty. If no credentials could be found for an existing device, | ||
* the result must not be empty, but provide an empty {@link CredentialsReadResult}. | ||
* | ||
* @param key The key of the device. | ||
* @param key The key of the device. |
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.
remove tabs
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.
Done
* @param tenantId The tenantId to search devices. | ||
* @param pageSize The page size. | ||
* @param pageOffset The page offset. | ||
* @param filters The list of filters (currently only the first value of the list is used). |
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.
remove tabs
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.
Done
Also-by: Matthias Feurer [email protected] Signed-off-by: g.dimitropoulos <[email protected]>
Also-by: Matthias Feurer [email protected] Signed-off-by: g.dimitropoulos <[email protected]>
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.
LGTM
… management API Implement backend filter for H2 & Postgresql: - field/value filter - value filter of type bool/number/string - enable filter wildcards for string value - add documentation Also-by: Matthias Feurer <[email protected]> Signed-off-by: George Dimitropoulos <[email protected]>
Hono Issue for PR
Implement backend filter for H2 & Postgresql :
Also-by: Matthias Feurer [email protected]
Signed-off-by: g.dimitropoulos [email protected]