Skip to content

Commit 39b35a9

Browse files
committed
use non-common separator for group_concat in barcodes
1 parent 4397340 commit 39b35a9

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [0.51.5]
5+
6+
### Fixed
7+
- Fixed crash when parsing a barcode with a comma in it
8+
49
## [0.51.4]
510

611
### Fixed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ allprojects {
3131
}
3232

3333
project.ext {
34-
sdkVersion='0.51.4'
34+
sdkVersion='0.51.5'
3535
versionCode=1
3636

3737
compileSdkVersion=31

core/src/main/java/io/snabble/sdk/ProductDatabase.java

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public class ProductDatabase {
4141
private static final String METADATA_DEFAULT_AVAILABILITY = "defaultAvailability";
4242
private static final String METADATA_KEY_LAST_UPDATE_TIMESTAMP = "app_lastUpdateTimestamp";
4343

44+
private static final String SEPARATOR = "·";
45+
4446
private SQLiteDatabase db;
4547
private Product.Type[] productTypes = Product.Type.values();
4648

@@ -794,7 +796,7 @@ public Product productAtCursor(Cursor cursor) {
794796

795797
String codes = cursor.getString(7);
796798
if (codes != null) {
797-
lookupCodes = codes.split(",");
799+
lookupCodes = codes.split(SEPARATOR);
798800
}
799801

800802
builder.setSubtitle(cursor.getString(8));
@@ -808,7 +810,7 @@ public Product productAtCursor(Cursor cursor) {
808810
if (lookupCodes != null) {
809811
String transmissionCodesStr = cursor.getString(12);
810812
if (transmissionCodesStr != null) {
811-
transmissionCodes = transmissionCodesStr.split(",", -1);
813+
transmissionCodes = transmissionCodesStr.split(SEPARATOR, -1);
812814
}
813815
}
814816

@@ -831,17 +833,17 @@ public Product productAtCursor(Cursor cursor) {
831833
if (lookupCodes != null) {
832834
String encodingUnitsStr = cursor.getString(15);
833835
if (encodingUnitsStr != null) {
834-
codeEncodingUnits = encodingUnitsStr.split(",", -1);
836+
codeEncodingUnits = encodingUnitsStr.split(SEPARATOR, -1);
835837
}
836838

837839
String templatesStr = cursor.getString(16);
838840
if (templatesStr != null) {
839-
templates = templatesStr.split(",", -1);
841+
templates = templatesStr.split(SEPARATOR, -1);
840842
}
841843

842844
String isPrimaryStr = cursor.getString(17);
843845
if (isPrimaryStr != null) {
844-
String[] split = isPrimaryStr.split(",", -1);
846+
String[] split = isPrimaryStr.split(SEPARATOR, -1);
845847
if (split.length > 0) {
846848
codeIsPrimaryCode = new boolean[split.length];
847849
for (int i=0; i<split.length; i++) {
@@ -856,7 +858,7 @@ public Product productAtCursor(Cursor cursor) {
856858

857859
String specifiedQuantities = cursor.getString(18);
858860
if (specifiedQuantities != null) {
859-
String[] split = specifiedQuantities.split(",", -1);
861+
String[] split = specifiedQuantities.split(SEPARATOR, -1);
860862
if (split.length > 0) {
861863
codeSpecifiedQuantities = new int[split.length];
862864
for (int i=0; i<split.length; i++) {
@@ -872,7 +874,7 @@ public Product productAtCursor(Cursor cursor) {
872874

873875
String transmissionTemplatesStr = cursor.getString(19);
874876
if (transmissionTemplatesStr != null) {
875-
transmissionTemplates = transmissionTemplatesStr.split(",", -1);
877+
transmissionTemplates = transmissionTemplatesStr.split(SEPARATOR, -1);
876878
}
877879
}
878880

@@ -890,6 +892,8 @@ public Product productAtCursor(Cursor cursor) {
890892
CodeTemplate template = null;
891893
CodeTemplate transmissionTemplate = null;
892894

895+
// BRAINDUMP: transmissionCodes und productCodes length !=
896+
893897
if (transmissionCodes != null) {
894898
String tc = transmissionCodes[i];
895899
if (!tc.equals("")) {
@@ -1036,19 +1040,19 @@ private String productSqlString(String appendFields, String appendSql, boolean d
10361040
"p.depositSku," +
10371041
"p.isDeposit," +
10381042
"p.weighing," +
1039-
"(SELECT group_concat(s.code) FROM scannableCodes s WHERE s.sku = p.sku)," +
1043+
"(SELECT group_concat(s.code, \"" + SEPARATOR + "\") FROM scannableCodes s WHERE s.sku = p.sku)," +
10401044
"p.subtitle" +
10411045
",p.saleRestriction"+
10421046
",p.saleStop" +
10431047
",p.notForSale" +
1044-
",(SELECT group_concat(ifnull(s.transmissionCode, \"\")) FROM scannableCodes s WHERE s.sku = p.sku)" +
1048+
",(SELECT group_concat(ifnull(s.transmissionCode, \"\"), \"" + SEPARATOR + "\") FROM scannableCodes s WHERE s.sku = p.sku)" +
10451049
",p.referenceUnit" +
10461050
",p.encodingUnit" +
1047-
",(SELECT group_concat(ifnull(s.encodingUnit, \"\")) FROM scannableCodes s WHERE s.sku = p.sku)" +
1048-
",(SELECT group_concat(ifnull(s.template, \"\")) FROM scannableCodes s WHERE s.sku = p.sku)" +
1049-
",(SELECT group_concat(ifnull(sc.isPrimary, '')) FROM scannableCodes sc where sc.sku = p.sku)" +
1050-
",(SELECT group_concat(ifnull(sc.specifiedQuantity, '')) FROM scannableCodes sc where sc.sku = p.sku)" +
1051-
",(SELECT group_concat(ifnull(sc.transmissionTemplate, '')) FROM scannableCodes sc where sc.sku = p.sku)" +
1051+
",(SELECT group_concat(ifnull(s.encodingUnit, \"\"), \"" + SEPARATOR + "\") FROM scannableCodes s WHERE s.sku = p.sku)" +
1052+
",(SELECT group_concat(ifnull(s.template, \"\"), \"" + SEPARATOR + "\") FROM scannableCodes s WHERE s.sku = p.sku)" +
1053+
",(SELECT group_concat(ifnull(sc.isPrimary, ''), \"" + SEPARATOR + "\") FROM scannableCodes sc where sc.sku = p.sku)" +
1054+
",(SELECT group_concat(ifnull(sc.specifiedQuantity, ''), \"" + SEPARATOR + "\") FROM scannableCodes sc where sc.sku = p.sku)" +
1055+
",(SELECT group_concat(ifnull(sc.transmissionTemplate, ''), \"" + SEPARATOR + "\") FROM scannableCodes sc where sc.sku = p.sku)" +
10521056
",p.scanMessage" +
10531057
",ifnull((SELECT a.value FROM availabilities a WHERE a.sku = p.sku AND a.shopID = " + shopId + "), " + defaultAvailability + ") as availability" +
10541058
appendFields +

0 commit comments

Comments
 (0)