diff --git a/store/shared/src/commonMain/kotlin/maryk/datastore/shared/optimizeTableScan.kt b/store/shared/src/commonMain/kotlin/maryk/datastore/shared/optimizeTableScan.kt index 6105a4a6..a5ed82fc 100644 --- a/store/shared/src/commonMain/kotlin/maryk/datastore/shared/optimizeTableScan.kt +++ b/store/shared/src/commonMain/kotlin/maryk/datastore/shared/optimizeTableScan.kt @@ -52,8 +52,10 @@ fun DM.optimizeTableScan( } } - if (keyScanRanges.equalBytes < (this.Meta.minimumKeyScanByteRange ?: this.Meta.keyByteSize.toUInt())) { - throw StorageException("Key scan bytes (${keyScanRanges.equalBytes}) must be more or equal than minimum key scan bytes (${this.Meta.minimumKeyScanByteRange}). Or set an order to guide scan to an index") + val minimumKeyScanByteRange = this.Meta.minimumKeyScanByteRange ?: this.Meta.keyByteSize.toUInt() + + if (keyScanRanges.equalBytes < minimumKeyScanByteRange) { + throw StorageException("Key scan bytes (${keyScanRanges.equalBytes}) must be more or equal than minimum key scan bytes ($minimumKeyScanByteRange). Or set an order to guide scan to an index") } return tableScan