-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
DB specific length support in JSONs/Varchars/binary data #3107
Changes from 12 commits
2867c50
81443b7
f5d0777
0dc4c6b
f499cc8
2a7a2d4
e898910
0f9462b
578560c
d1c21bf
6fe3ec9
f63b013
d823873
7761067
994fb26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ class ClickHouseDbArray { | |
mapping.put("integer[]", "Array(UInt32)"); | ||
mapping.put("bigint[]", "Array(UInt64)"); | ||
mapping.put("float[]", "Array(Float32)"); | ||
mapping.put("float4[]", "Array(Float32)"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There were some issues for Clickhouse. They are in commit 81443b7 |
||
mapping.put("decimal[]", "Array(Decimal)"); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -279,7 +279,13 @@ public String convert(String type) { | |
if (type == null) { | ||
return null; | ||
} | ||
type = extract(type); | ||
String[] tmp = type.split(";", -1); // do not discard trailing empty strings | ||
int index = extract(tmp); | ||
if (index < tmp.length - 1) { | ||
// this is a platform specific definition. So do not apply further conversions | ||
return tmp[index]; | ||
} | ||
type = tmp[index]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This detects, if there is a platform specific definition, e.g. |
||
if (type.contains("[]")) { | ||
return convertArrayType(type); | ||
} | ||
|
@@ -294,18 +300,22 @@ protected String extract(String type) { | |
return null; | ||
} | ||
String[] tmp = type.split(";", -1); // do not discard trailing empty strings | ||
if (tmp.length % 2 == 0) { | ||
throw new IllegalArgumentException("You need an odd number of arguments in '" + type + "'. See Issue #2559 for details"); | ||
return tmp[extract(tmp)]; // else | ||
} | ||
|
||
protected int extract(String[] types) { | ||
if (types.length % 2 == 0) { | ||
throw new IllegalArgumentException("You need an odd number of arguments in '" + String.join(";", types) + "'. See Issue #2559 for details"); | ||
} | ||
for (int i = 0; i < tmp.length - 2; i += 2) { | ||
String[] platforms = tmp[i].split(","); | ||
for (int i = 0; i < types.length - 2; i += 2) { | ||
String[] platforms = types[i].split(","); | ||
for (String plat : platforms) { | ||
if (platform.isPlatform(Platform.valueOf(plat.toUpperCase(Locale.ENGLISH)))) { | ||
return tmp[i + 1]; | ||
return i + 1; | ||
} | ||
} | ||
} | ||
return tmp[tmp.length - 1]; // else | ||
return types.length - 1; // else | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package misc.migration.v1_1; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.Id; | ||
import javax.persistence.Table; | ||
import javax.validation.constraints.Size; | ||
|
||
@Entity | ||
@Table(name = "migtest_e_test_binary") | ||
public class ETestBinary { | ||
|
||
@Id | ||
int id; | ||
|
||
@Size(max = 16) | ||
byte[] test_byte16; | ||
|
||
@Size(max = 256) | ||
byte[] test_byte256; | ||
|
||
@Size(max = 512) | ||
byte[] test_byte512; | ||
|
||
@Size(max = 1024) | ||
byte[] test_byte1k; | ||
|
||
@Size(max = 2 * 1024) | ||
byte[] test_byte2k; | ||
|
||
@Size(max = 4 * 1024) | ||
byte[] test_byte4k; | ||
|
||
@Size(max = 8 * 1024) | ||
byte[] test_byte8k; | ||
|
||
@Size(max = 16 * 1024) | ||
byte[] test_byte16k; | ||
|
||
@Size(max = 32 * 1024) | ||
byte[] test_byte32k; | ||
|
||
@Size(max = 64 * 1024) | ||
byte[] test_byte64k; | ||
|
||
@Size(max = 128 * 1024) | ||
byte[] test_byte128k; | ||
|
||
@Size(max = 256 * 1024) | ||
byte[] test_byte256k; | ||
|
||
@Size(max = 512 * 1024) | ||
byte[] test_byte512k; | ||
|
||
@Size(max = 1024 * 1024) | ||
byte[] test_byte1m; | ||
|
||
@Size(max = 2 * 1024 * 1024) | ||
byte[] test_byte2m; | ||
|
||
@Size(max = 4 * 1024 * 1024) | ||
byte[] test_byte4m; | ||
|
||
@Size(max = 8 * 1024 * 1024) | ||
byte[] test_byte8m; | ||
|
||
@Size(max = 16 * 1024 * 1024) | ||
byte[] test_byte16m; | ||
|
||
@Size(max = 32 * 1024 * 1024) | ||
byte[] test_byte32m; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package misc.migration.v1_1; | ||
|
||
import io.ebean.annotation.DbJson; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.Id; | ||
import javax.persistence.Table; | ||
import java.util.List; | ||
|
||
@Entity | ||
@Table(name = "migtest_e_test_json") | ||
public class ETestJson { | ||
|
||
@Id | ||
int id; | ||
|
||
@DbJson(length = 255) | ||
List<String> json255; | ||
|
||
@DbJson(length = 256) | ||
List<String> json256; | ||
|
||
@DbJson(length = 512) | ||
List<String> json512; | ||
|
||
@DbJson(length = 1024) | ||
List<String> json1k; | ||
|
||
@DbJson(length = 2 * 1024) | ||
List<String> json2k; | ||
|
||
@DbJson(length = 4 * 1024) | ||
List<String> json4k; | ||
|
||
@DbJson(length = 8 * 1024) | ||
List<String> json8k; | ||
|
||
@DbJson(length = 16 * 1024) | ||
List<String> json16k; | ||
|
||
@DbJson(length = 32 * 1024) | ||
List<String> json32k; | ||
|
||
@DbJson(length = 64 * 1024) | ||
List<String> json64k; | ||
|
||
@DbJson(length = 128 * 1024) | ||
List<String> json128k; | ||
|
||
@DbJson(length = 256 * 1024) | ||
List<String> json256k; | ||
|
||
@DbJson(length = 512 * 1024) | ||
List<String> json512k; | ||
|
||
@DbJson(length = 1024 * 1024) | ||
List<String> json1m; | ||
|
||
@DbJson(length = 2 * 1024 * 1024) | ||
List<String> json2m; | ||
|
||
@DbJson(length = 4 * 1024 * 1024) | ||
List<String> json4m; | ||
|
||
@DbJson(length = 8 * 1024 * 1024) | ||
List<String> json8m; | ||
|
||
@DbJson(length = 16 * 1024 * 1024) | ||
List<String> json16m; | ||
|
||
@DbJson(length = 32 * 1024 * 1024) | ||
List<String> json32m; | ||
|
||
} |
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 can remove the sqlserver workaround now