use of com.mysql.cj.xdevapi.SessionFactory in project aws-mysql-jdbc by awslabs.
the class CollectionTest method testArrayIndex005.
@Test
public void testArrayIndex005() throws Exception {
assumeTrue(mysqlVersionMeetsMinimum(this.baseUrl, ServerVersion.parseVersion("8.0.17")), "MySQL 8.0.17+ is required to run this test.");
String collname = "coll1";
Session sess = null;
try {
sess = new SessionFactory().getSession(this.baseUrl);
Schema sch = sess.getDefaultSchema();
sch.dropCollection(collname);
Collection coll = sch.createCollection(collname, true);
/* create basic index */
coll.createIndex("multiArrayIndex", "{\"fields\": [{\"field\": \"$.intField\", \"type\": \"INTEGER\", \"array\": false}," + "{\"field\": \"$.charField\", \"type\": \"CHAR(255)\", \"array\": true}," + "{\"field\": \"$.decimalField\", \"type\": \"DECIMAL\", \"array\": false}," + "{\"field\": \"$.dateField\", \"type\": \"DATE\", \"array\": false}," + "{\"field\": \"$.timeField\", \"type\": \"TIME\", \"array\": false}," + "{\"field\": \"$.datetimeField\", \"type\": \"DATETIME\", \"array\": false}]}");
validateArrayIndex("multiArrayIndex", "coll1", 6);
coll.add("{\"intField\" : 12, \"uintField\" : [51,52,53], \"dateField\" : \"2019-1-1\", \"datetimeField\" : \"9999-12-31 23:59:59\", \"charField\" : [\"abcd1\", \"abcd2\", \"abcd3\", \"abcd4\"], \"binaryField\" : \"abcd1\", \"timeField\" : \"10.30\", \"decimalField\" : 51.2}").execute();
coll.add("{\"intField\" : 12, \"uintField\" : [51,52,53], \"dateField\" : \"2019-1-1\", \"datetimeField\" : \"9999-12-31 23:59:59\", \"charField\" : [\"abcd1\", \"abcd2\", \"abcd3\", \"abcd4\"], \"binaryField\" : \"abcd1\", \"timeField\" : \"10.30\", \"decimalField\" : 51.2}").execute();
coll.add("{\"intField\" : 12, \"uintField\" : [51,52,53], \"dateField\" : \"2019-1-1\", \"datetimeField\" : \"9999-12-31 23:59:59\", \"charField\" : [\"abcd1\", \"abcd2\", \"abcd3\", \"abcd4\"], \"binaryField\" : \"abcd1\", \"timeField\" : \"10.30\", \"decimalField\" : 51.2}").execute();
coll.add("{\"intField\" : 18, \"uintField\" : [51,52,53], \"dateField\" : \"2019-1-1\", \"datetimeField\" : \"9999-12-31 23:59:59\", \"charField\" : [\"abcd1\", \"abcd2\", \"abcd3\", \"abcd4\"], \"binaryField\" : \"abcd1\", \"timeField\" : \"10.30\", \"decimalField\" : 51.2}").execute();
try {
coll.add("{\"intField\" : \"[12,23,34]\", \"dateField\" : [\"2019-1-1\", \"2019-2-1\", \"2019-3-1\"], \"charField\" : [\"abcd1\", \"abcd1\", \"abcd2\", \"abcd4\"], \"timeField\" : [\"10.30\", \"11.30\", \"12.30\"]}").execute();
assertTrue(false);
} catch (Exception e) {
System.out.println("ERROR : " + e.getMessage());
assertTrue(e.getMessage().contains("Invalid JSON value for CAST to INTEGER from column json_extract at row"));
}
try {
coll.add("{\"intField\" : 12, \"dateField\" : \"2019-1-1\", \"charField\" : [\"abcd1\", \"abcd1\", \"abcd2\", \"abcd4\"], \"timeField\" : \"10.30\"}").execute();
// Behavior documented : assertTrue(false);
} catch (Exception e) {
System.out.println("ERROR : " + e.getMessage());
assertTrue(e.getMessage().contains("Incorrect char value"));
}
sch.dropCollection(collname);
} finally {
if (sess != null) {
sess.close();
sess = null;
}
}
}
use of com.mysql.cj.xdevapi.SessionFactory in project aws-mysql-jdbc by awslabs.
the class CollectionTest method testArrayIndex003.
@Test
public void testArrayIndex003() throws Exception {
assumeTrue(mysqlVersionMeetsMinimum(this.baseUrl, ServerVersion.parseVersion("8.0.17")), "MySQL 8.0.17+ is required to run this test.");
String collname = "coll1";
Session sess = null;
try {
sess = new SessionFactory().getSession(this.baseUrl);
Schema sch = sess.getDefaultSchema();
sch.dropCollection(collname);
Collection coll = sch.createCollection(collname, true);
try {
coll.createIndex("multiArrayIndex", "{\"fields\": [{\"field\": \"$.intField\", \"type\": \"SIGNED INTEGER\", \"array\": true}, {\"field\": \"$.dateField\", \"type\": \"DATE\", \"array\": true}, {\"field\": \"$.charField\", \"type\": \"CHAR(256)\", \"array\": true}, {\"field\": \"$.timeField\", \"type\": \"TIME\", \"array\": true}]}");
} catch (Exception e) {
System.out.println("ERROR : " + e.getMessage());
assertTrue(e.getMessage().contains("This version of MySQL doesn't yet support"));
}
sch.dropCollection(collname);
} finally {
if (sess != null) {
sess.close();
sess = null;
}
}
}
use of com.mysql.cj.xdevapi.SessionFactory in project aws-mysql-jdbc by awslabs.
the class CollectionTest method testArrayIndex015.
@Test
public void testArrayIndex015() throws Exception {
assumeTrue(mysqlVersionMeetsMinimum(this.baseUrl, ServerVersion.parseVersion("8.0.17")), "MySQL 8.0.17+ is required to run this test.");
String collname = "coll1";
DbDoc doc = null;
Session sess = null;
try {
sess = new SessionFactory().getSession(this.baseUrl);
Schema sch = sess.getDefaultSchema();
sch.dropCollection(collname);
Collection coll = sch.createCollection(collname, true);
/* create basic index */
coll.remove("true").execute();
coll.add("{\"_id\":1,\"name\":\"decimalArray1\",\"decimalField1\":[835975.76,87349829932749.67,89248481498149882498141.12],\"decimalField2\":[835975.76,87349829932.839],\"decimalField3\":[835977.76,87349829932.839]}").execute();
coll.add("{\"_id\":2,\"name\":\"dateArray1\",\"dateField1\" : [\"2017-12-12\",\"2018-12-12\",\"2019-12-12\"],\"dateField2\" : [\"2017-12-12\",\"2018-11-11\",\"2019-11-11\"],\"dateField3\" : [\"2017-12-12\",\"2018-10-10\",\"2019-10-10\"]}").execute();
coll.add("{\"_id\":3,\"name\":\"timeArray1\",\"timeField1\" : [\"12:20\",\"11:20\",\"10:20\"], \"timeField2\" : [\"12:00\",\"11:00\",\"10:20\"], \"timeField3\" : [\"12:10\",\"11:10\",\"10:00\"]}").execute();
coll.add("{\"_id\":4,\"name\":\"timestampArray1\",\"timestampField1\" : [\"2017-12-12 20:12:07\", \"2018-12-12 20:12:07\",\"2019-12-12 20:12:07\"], \"timestampField2\" : [\"2017-12-12 20:12:07\", \"2018-11-11 20:12:07\",\"2019-11-11 20:12:07\"], \"timestampField3\" : [\"2017-12-12 20:12:07\", \"2018-10-11 20:12:07\",\"2019-12-12 20:12:07\"]}").execute();
coll.add("{\"_id\":5,\"name\":\"datetimeArray1\", \"datetimeField1\" : [\"2017-12-12 20:12:07\", \"2018-12-12 20:12:07\",\"2019-12-12 20:12:07\"], \"datetimeField2\" : [\"2017-12-12 20:12:07\", \"2018-11-11 20:12:07\",\"2019-11-11 20:12:07\"],\"datetimeField3\" : [\"2017-10-10 20:12:07\", \"2018-10-10 20:12:07\",\"2019-10-10 20:12:07\"]}").execute();
coll.add("{\"_id\":6,\"name\":\"binaryArray1\", \"binaryField1\":[\"0xe240\",\"0x0001e240\"],\"binaryField2\":[\"0xe240\",\"0x0001e240\"],\"binaryField3\":[\"0xe240\",\"0x0001e240\"]}").execute();
coll.add("{\"_id\":7,\"name\":\"dateArray2\",\"dateField1\" : [\"2017-12-12\",\"2018-12-12\",\"2019-12-12\"],\"dateField2\" : [\"2017-11-11\",\"2018-11-11\",\"2019-11-11\"],\"dateField3\" : [\"2017-10-10\",\"2018-10-10\",\"2019-10-10\"]}").execute();
coll.add("{\"_id\":8,\"name\":\"timeArray2\",\"timeField1\" : [\"12:20\",\"11:20\",\"10:20\"], \"timeField2\" : [\"12:00\",\"11:00\",\"10:00\"], \"timeField3\" : [\"12:10\",\"11:10\",\"10:10\"]}").execute();
coll.add("{\"_id\":9,\"name\":\"datetimeArray2\", \"datetimeField1\" : [\"2017-12-12 20:12:07\", \"2018-12-12 20:12:07\",\"2019-12-12 20:12:07\"], \"datetimeField2\" : [\"2017-11-11 20:12:07\", \"2018-11-11 20:12:07\",\"2019-11-11 20:12:07\"],\"datetimeField3\" : [\"2017-10-10 20:12:07\", \"2018-10-10 20:12:07\",\"2019-10-10 20:12:07\"]}").execute();
coll.add("{\"_id\":10,\"name\":\"binaryArray2\", \"binaryField1\":[\"0xe240\",\"0x0001e240\"],\"binaryField2\":[\"0xe2040\",\"0x0001e2040\"],\"binaryField3\":[\"0xe02040\",\"0x0001e02040\"]}").execute();
coll.add("{\"_id\":11,\"name\":\"charArray1\", \"charField1\":[\"char1\",\"char2\"],\"charField2\":[\"char1\",\"char3\"],\"charField3\":[\"char1\",\"char2\"]}").execute();
coll.add("{\"_id\":12,\"name\":\"charArray2\", \"charField1\":[\"char1\",\"char2\"],\"charField2\":[\"char3\",\"char4\"],\"charField3\":[\"char5\",\"char6\"]}").execute();
coll.add("{\"_id\":13,\"name\":\"intArray1\", \"intField1\":[-15,-25],\"intField2\":[-15,-20],\"intField3\":[-10,-20]}").execute();
coll.add("{\"_id\":14,\"name\":\"intArray2\", \"intField1\":[-10,-20],\"intField2\":[-30,-40],\"intField3\":[-50,-60]}").execute();
coll.add("{\"_id\":15,\"name\":\"uintArray1\", \"uintField1\":[15,25],\"uintField2\":[15,20],\"uintField3\":[10,20]}").execute();
coll.add("{\"_id\":16,\"name\":\"uintArray2\", \"uintField1\":[10,20],\"uintField2\":[30,40],\"uintField3\":[50,60]}").execute();
coll.createIndex("intArrayIndex1", "{\"fields\": [{\"field\": \"$.intField1\", \"type\": \"SIGNED INTEGER\", \"array\": true}]}");
coll.createIndex("intArrayIndex2", "{\"fields\": [{\"field\": \"$.intField2\", \"type\": \"SIGNED INTEGER\", \"array\": true}]}");
coll.createIndex("uintArrayIndex1", "{\"fields\": [{\"field\": \"$.uintField1\", \"type\": \"UNSIGNED INTEGER\", \"array\": true}]}");
coll.createIndex("uintArrayIndex2", "{\"fields\": [{\"field\": \"$.uintField2\", \"type\": \"UNSIGNED INTEGER\", \"array\": true}]}");
coll.createIndex("decimalArrayIndex1", "{\"fields\": [{\"field\": \"$.decimalField1\", \"type\": \"DECIMAL(65,2)\", \"array\": true}]}");
coll.createIndex("decimalArrayIndex2", "{\"fields\": [{\"field\": \"$.decimalField2\", \"type\": \"DECIMAL(65,2)\", \"array\": true}]}");
coll.createIndex("dateArrayIndex1", "{\"fields\": [{\"field\": \"$.dateField1\", \"type\": \"DATE\", \"array\": true}]}");
coll.createIndex("dateArrayIndex2", "{\"fields\": [{\"field\": \"$.dateField2\", \"type\": \"DATE\", \"array\": true}]}");
coll.createIndex("datetimeArrayIndex1", "{\"fields\": [{\"field\": \"$.datetimeField1\", \"type\": \"DATETIME\", \"array\": true}]}");
coll.createIndex("datetimeArrayIndex2", "{\"fields\": [{\"field\": \"$.datetimeField2\", \"type\": \"DATETIME\", \"array\": true}]}");
coll.createIndex("timeArrayIndex1", "{\"fields\": [{\"field\": \"$.timeField1\", \"type\": \"TIME\", \"array\": true}]}");
coll.createIndex("timeArrayIndex2", "{\"fields\": [{\"field\": \"$.timeField2\", \"type\": \"TIME\", \"array\": true}]}");
coll.createIndex("charArrayIndex1", "{\"fields\": [{\"field\": \"$.charField1\", \"type\": \"CHAR(256)\", \"array\": true}]}");
coll.createIndex("charArrayIndex2", "{\"fields\": [{\"field\": \"$.charField2\", \"type\": \"CHAR(256)\", \"array\": true}]}");
coll.createIndex("binaryArrayIndex1", "{\"fields\": [{\"field\": \"$.binaryField1\", \"type\": \"BINARY(256)\", \"array\": true}]}");
coll.createIndex("binaryArrayIndex2", "{\"fields\": [{\"field\": \"$.binaryField2\", \"type\": \"BINARY(256)\", \"array\": true}]}");
validateArrayIndex("intArrayIndex1", "coll1", 1);
validateArrayIndex("uintArrayIndex1", "coll1", 1);
validateArrayIndex("decimalArrayIndex1", "coll1", 1);
validateArrayIndex("dateArrayIndex1", "coll1", 1);
validateArrayIndex("datetimeArrayIndex1", "coll1", 1);
validateArrayIndex("timeArrayIndex1", "coll1", 1);
validateArrayIndex("charArrayIndex1", "coll1", 1);
validateArrayIndex("binaryArrayIndex1", "coll1", 1);
validateArrayIndex("intArrayIndex2", "coll1", 1);
validateArrayIndex("uintArrayIndex2", "coll1", 1);
validateArrayIndex("decimalArrayIndex2", "coll1", 1);
validateArrayIndex("dateArrayIndex2", "coll1", 1);
validateArrayIndex("datetimeArrayIndex2", "coll1", 1);
validateArrayIndex("timeArrayIndex2", "coll1", 1);
validateArrayIndex("charArrayIndex2", "coll1", 1);
validateArrayIndex("binaryArrayIndex2", "coll1", 1);
DocResult docs = coll.find("$.intField1 overlaps $.intField2").execute();
assertTrue(docs.count() == 1);
doc = docs.next();
assertEquals("intArray1", ((JsonString) doc.get("name")).getString());
docs = coll.find("$.intField1 not overlaps $.intField2").execute();
assertTrue(docs.count() == 1);
doc = docs.next();
assertEquals("intArray2", ((JsonString) doc.get("name")).getString());
docs = coll.find("$.uintField1 overlaps $.uintField2").execute();
assertTrue(docs.count() == 1);
doc = docs.next();
assertEquals("uintArray1", ((JsonString) doc.get("name")).getString());
docs = coll.find("$.uintField1 not overlaps $.uintField2").execute();
assertTrue(docs.count() == 1);
doc = docs.next();
assertEquals("uintArray2", ((JsonString) doc.get("name")).getString());
docs = coll.find("$.charField1 overlaps $.charField2").execute();
assertTrue(docs.count() == 1);
doc = docs.next();
assertEquals("charArray1", ((JsonString) doc.get("name")).getString());
docs = coll.find("$.charField1 not overlaps $.charField2").execute();
assertTrue(docs.count() == 1);
doc = docs.next();
assertEquals("charArray2", ((JsonString) doc.get("name")).getString());
docs = coll.find("$.decimalField1 overlaps $.decimalField2").execute();
assertTrue(docs.count() == 1);
doc = docs.next();
assertEquals("decimalArray1", ((JsonString) doc.get("name")).getString());
docs = coll.find("$.decimalField1 not overlaps $.decimalField2").execute();
assertTrue(docs.count() == 0);
docs = coll.find("$.binaryField1 overlaps $.binaryField2").execute();
assertTrue(docs.count() == 1);
doc = docs.next();
assertEquals("binaryArray1", ((JsonString) doc.get("name")).getString());
docs = coll.find("$.binaryField1 not overlaps $.binaryField2").execute();
assertTrue(docs.count() == 1);
doc = docs.next();
assertEquals("binaryArray2", ((JsonString) doc.get("name")).getString());
docs = coll.find("$.timeField1 overlaps $.timeField2").execute();
assertTrue(docs.count() == 1);
doc = docs.next();
assertEquals("timeArray1", ((JsonString) doc.get("name")).getString());
docs = coll.find("$.timeField1 not overlaps $.timeField2").execute();
assertTrue(docs.count() == 1);
doc = docs.next();
assertEquals("timeArray2", ((JsonString) doc.get("name")).getString());
docs = coll.find("$.datetimeField1 overlaps $.datetimeField2").execute();
assertTrue(docs.count() == 1);
doc = docs.next();
assertEquals("datetimeArray1", ((JsonString) doc.get("name")).getString());
docs = coll.find("$.datetimeField1 not overlaps $.datetimeField2").execute();
assertTrue(docs.count() == 1);
doc = docs.next();
assertEquals("datetimeArray2", ((JsonString) doc.get("name")).getString());
docs = coll.find("$.dateField1 overlaps $.dateField2").execute();
assertTrue(docs.count() == 1);
doc = docs.next();
assertEquals("dateArray1", ((JsonString) doc.get("name")).getString());
docs = coll.find("$.dateField1 not overlaps $.dateField2").execute();
assertTrue(docs.count() == 1);
doc = docs.next();
assertEquals("dateArray2", ((JsonString) doc.get("name")).getString());
sch.dropCollection(collname);
} finally {
if (sess != null) {
sess.close();
sess = null;
}
}
}
use of com.mysql.cj.xdevapi.SessionFactory in project aws-mysql-jdbc by awslabs.
the class CollectionTest method testArrayIndex004.
@Test
public void testArrayIndex004() throws Exception {
assumeTrue(mysqlVersionMeetsMinimum(this.baseUrl, ServerVersion.parseVersion("8.0.17")), "MySQL 8.0.17+ is required to run this test.");
String collname = "coll1";
Session sess = null;
try {
sess = new SessionFactory().getSession(this.baseUrl);
Schema sch = sess.getDefaultSchema();
sch.dropCollection(collname);
Collection coll = sch.createCollection(collname, true);
/* create basic index */
String indexString = "{\"fields\": [{\"field\": \"$.intField\", \"type\": \"UNSIGNED INTEGER\", \"array\": true}," + "{\"field\": \"$.charField\", \"type\": \"CHAR(255)\", \"array\": false}," + "{\"field\": \"$.decimalField\", \"type\": \"DECIMAL\", \"array\": false}," + "{\"field\": \"$.dateField\", \"type\": \"DATE\", \"array\": false}," + "{\"field\": \"$.timeField\", \"type\": \"TIME\", \"array\": false}," + "{\"field\": \"$.datetimeField\", \"type\": \"DATETIME\", \"array\": false}]}";
coll.createIndex("multiArrayIndex", indexString);
// coll.createIndex("multiArrayIndex", "{\"fields\": [{\"field\": \"$.intField\", \"type\": \"INT\", \"array\": false}, {\"field\": \"$.dateField\", \"type\": \"DATE\", \"array\": false}, {\"field\": \"$.charField\", \"type\": \"CHAR(256)\", \"array\": true}, {\"field\": \"$.timeField\", \"type\": \"TIME\", \"array\": false}]}");
validateArrayIndex("multiArrayIndex", "coll1", 6);
coll.add("{\"intField\" : [12,23,34], \"uintField\" : [51,52,53], \"dateField\" : \"2019-1-1\", \"datetimeField\" : \"9999-12-31 23:59:59\", \"charField\" : \"abcd1\", \"binaryField\" : \"abcd1\", \"timeField\" : \"10.30\", \"decimalField\" : 51.2}").execute();
coll.add("{\"intField\" : [12,25,34], \"uintField\" : [51,52,53], \"dateField\" : \"2019-1-1\", \"datetimeField\" : \"9999-12-31 23:59:59\", \"charField\" : \"abcd1\", \"binaryField\" : \"abcd1\", \"timeField\" : \"10.30\", \"decimalField\" : 51.2}").execute();
coll.add("{\"intField\" : [12,23,35], \"uintField\" : [51,52,53], \"dateField\" : \"2019-1-1\", \"datetimeField\" : \"9999-12-31 23:59:59\", \"charField\" : \"abcd1\", \"binaryField\" : \"abcd1\", \"timeField\" : \"10.30\", \"decimalField\" : 51.2}").execute();
coll.add("{\"intField\" : [18,23,34], \"uintField\" : [51,52,53], \"dateField\" : \"2019-1-1\", \"datetimeField\" : \"9999-12-31 23:59:59\", \"charField\" : \"abcd1\", \"binaryField\" : \"abcd1\", \"timeField\" : \"10.30\", \"decimalField\" : 51.2}").execute();
try {
coll.add("{\"intField\" : [12,23,34], \"dateField\" : [\"2019-1-1\", \"2019-2-1\", \"2019-3-1\"], \"charField\" : [\"abcd1\", \"abcd1\", \"abcd2\", \"abcd4\"], \"timeField\" : \"10.30\"}").execute();
assertTrue(false);
} catch (Exception e) {
System.out.println("ERROR : " + e.getMessage());
assertTrue(e.getMessage().contains("Incorrect date value"));
}
try {
coll.add("{\"intField\" : 35, \"dateField\" : \"2019-1-1\", \"charField\" : [\"abcd1\", \"abcd1\", \"abcd2\", \"abcd4\"], \"timeField\" : [\"10.30\", \"11.30\", \"12.30\"]}").execute();
assertTrue(false);
} catch (Exception e) {
System.out.println("ERROR : " + e.getMessage());
assertTrue(e.getMessage().contains("Incorrect time value"));
}
sch.dropCollection(collname);
} finally {
if (sess != null) {
sess.close();
sess = null;
}
}
}
use of com.mysql.cj.xdevapi.SessionFactory in project aws-mysql-jdbc by awslabs.
the class CollectionTest method testArrayIndex001.
/**
* START testArrayIndexBasic tests
*
* @throws Exception
*/
@Test
public void testArrayIndex001() throws Exception {
assumeTrue(mysqlVersionMeetsMinimum(this.baseUrl, ServerVersion.parseVersion("8.0.17")), "MySQL 8.0.17+ is required to run this test.");
int i = 0;
String collname = "coll1";
Session sess = null;
try {
sess = new SessionFactory().getSession(this.baseUrl);
Schema sch = sess.getDefaultSchema();
sch.dropCollection(collname);
Collection coll = sch.createCollection(collname, true);
/* create basic index */
coll.createIndex("intArrayIndex", "{\"fields\": [{\"field\": \"$.intField\", \"type\": \"SIGNED INTEGER\", \"array\": true}]}");
coll.createIndex("uintArrayIndex", "{\"fields\": [{\"field\": \"$.uintField\", \"type\": \"UNSIGNED INTEGER\", \"array\": true}]}");
coll.createIndex("floatArrayIndex", "{\"fields\": [{\"field\": \"$.floatField\", \"type\": \"DECIMAL(10,2)\", \"array\": true}]}");
coll.createIndex("dateArrayIndex", "{\"fields\": [{\"field\": \"$.dateField\", \"type\": \"DATE\", \"array\": true}]}");
coll.createIndex("datetimeArrayIndex", "{\"fields\": [{\"field\": \"$.datetimeField\", \"type\": \"DATETIME\", \"array\": true}]}");
coll.createIndex("timeArrayIndex", "{\"fields\": [{\"field\": \"$.timeField\", \"type\": \"TIME\", \"array\": true}]}");
coll.createIndex("charArrayIndex", "{\"fields\": [{\"field\": \"$.charField\", \"type\": \"CHAR(256)\", \"array\": true}]}");
coll.createIndex("binaryArrayIndex", "{\"fields\": [{\"field\": \"$.binaryField\", \"type\": \"BINARY(256)\", \"array\": true}]}");
validateArrayIndex("intArrayIndex", "coll1", 1);
validateArrayIndex("uintArrayIndex", "coll1", 1);
validateArrayIndex("floatArrayIndex", "coll1", 1);
validateArrayIndex("dateArrayIndex", "coll1", 1);
validateArrayIndex("datetimeArrayIndex", "coll1", 1);
validateArrayIndex("timeArrayIndex", "coll1", 1);
validateArrayIndex("charArrayIndex", "coll1", 1);
validateArrayIndex("binaryArrayIndex", "coll1", 1);
coll.remove("true").execute();
coll.add("{\"intField\" : [1,2,3], \"uintField\" : [51,52,53], \"dateField\" : [\"2019-1-1\", \"2019-2-1\", \"2019-3-1\"], \"datetimeField\" : [\"9999-12-30 23:59:59\", \"9999-12-31 23:59:59\", \"9999-12-31 23:59:59\"], \"charField\" : [\"abcd1\", \"abcd1\", \"abcd2\", \"abcd4\"], \"binaryField\" : [\"abcd1\", \"abcd1\", \"abcd2\", \"abcd4\"],\"timeField\" : [\"10.30\", \"11.30\", \"12.30\"], \"floatField\" : [51.2,52.4,53.6]}").execute();
coll.add("{\"intField\" : [11,12,3], \"uintField\" : [51,52,53], \"dateField\" : [\"2019-1-1\", \"2019-2-1\", \"2019-3-1\"], \"datetimeField\" : [\"9999-12-30 23:59:59\", \"9999-12-29 23:59:59\", \"9999-12-31 23:59:59\"], \"charField\" : [\"abcd1\", \"abcd1\", \"abcd2\", \"abcd4\"], \"binaryField\" : [\"abcd1\", \"abcd1\", \"abcd2\", \"abcd4\"], \"timeField\" : [\"10.30\", \"11.30\", \"12.30\"], \"floatField\" : [51.1,52.9,53.0]}").execute();
coll.add("{\"intField\" : [12,23,34], \"uintField\" : [51,52,53], \"dateField\" : [\"2019-1-1\", \"2019-2-1\", \"2019-3-1\"], \"datetimeField\" : [\"9999-12-31 23:59:59\", \"9999-12-31 23:59:59\", \"9999-12-7 23:59:59\"], \"charField\" : [\"abcd1\", \"abcd1\", \"abcd2\", \"abcd4\"], \"binaryField\" : [\"abcd1\", \"abcd1\", \"abcd2\", \"abcd4\"], \"timeField\" : [\"10.30\", \"11.30\", \"12.30\"], \"floatField\" : [51.2,52.7,53.6]}").execute();
try {
coll.add("{\"intField\" : \"[1,2,3]\", \"uintField\" : [51,52,53], \"dateField\" : [\"2019-1-1\", \"2019-2-1\", \"2019-3-1\"], \"datetimeField\" : [\"9999-12-30 23:59:59\", \"9999-12-31 23:59:59\", \"9999-12-31 23:59:59\"], \"charField\" : [\"abcd1\", \"abcd1\", \"abcd2\", \"abcd4\"], \"binaryField\" : [\"abcd1\", \"abcd1\", \"abcd2\", \"abcd4\"],\"timeField\" : [\"10.30\", \"11.30\", \"12.30\"], \"floatField\" : [51.2,52.4,53.6]}").execute();
assertTrue(false);
} catch (Exception e) {
System.out.println("ERROR : " + e.getMessage());
assertTrue(e.getMessage().contains("functional index"));
}
DocResult docs = coll.find(":intField in $.intField").bind("intField", 12).execute();
i = 0;
while (docs.hasNext()) {
docs.next();
i++;
}
assertTrue(i == 2);
docs = coll.find(":uintField in $.uintField").bind("uintField", 52).execute();
i = 0;
while (docs.hasNext()) {
docs.next();
i++;
}
assertTrue(i == 3);
docs = coll.find(":charField in $.charField").bind("charField", "abcd1").execute();
i = 0;
while (docs.hasNext()) {
docs.next();
i++;
}
assertTrue(i == 3);
docs = coll.find(":binaryField in $.binaryField").bind("binaryField", "abcd1").execute();
i = 0;
while (docs.hasNext()) {
docs.next();
i++;
}
assertTrue(i == 3);
sch.dropCollection(collname);
} finally {
if (sess != null) {
sess.close();
sess = null;
}
}
}
Aggregations