primary key and
jamesgaul opened this issue · comments
Query like this does not work...
query =
from(
a in Alert,
where:
a.pk == ^pk and fragment("begins_with(?, ?)", a.sk, ^alert_prefix)
)
Repo.all(query)
Returns no items but this does return all items where sk begins with alert_prefix string.
query =
from(
a in Alert,
where:
fragment("begins_with(?, ?)", a.sk, ^alert_prefix)
)
Repo.all(query)
Thank you for contacting us. It looks like the second example in your comment does work? (It's hard for me to tell from reading your comment.) Please see our README for exact examples of our current support for fragment
. If any of those examples are failing, please let us know. Otherwise, we would be happy to consider ideas as well as pull requests for future features.
A query like this on a composite global secondary index works for us.
attribute_value = ATTRIBUTE_VALUE
q = from(m in Model, where: m.hash_name == HASH_NAME and fragment("begins_with(?, ?)", m.attribute, ^attribute_value))
Repo.all(q)
Are you performing this query on a global secondary index or a composite primary key?
We've have confirmed and identified this issue and will keep it open, although we don't have a timeframe now for fixing it. Would using a global secondary index for this search be an acceptable workaround? (We've never had a cause to use begins_with
on a composite primary key since all our primary keys so far have been only hashes.)
Hi again. It looks like it won't be too bad. We'll try and get to it in the next few days. Thanks again for bringing it to our attention.
We've updated our GitHub release, extending the support we previously had on global secondary indexes to composite primary keys. Please let us know if you notice anything odd. Thanks again.