This commit is contained in:
parent
aa59f3ed1c
commit
889d42bc03
@ -63,6 +63,7 @@ import static org.jooq.util.mysql.MySQLDSL.sha1;
|
||||
import static org.jooq.util.mysql.MySQLDSL.sha2;
|
||||
import static org.jooq.util.mysql.MySQLDSL.uncompress;
|
||||
import static org.jooq.util.mysql.MySQLDSL.uncompressedLength;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
@ -843,12 +844,12 @@ public class MySQLTest extends jOOQAbstractTest<
|
||||
assertNotNull(create().select(password(MESSAGE)).fetchOne(0));
|
||||
assertNotNull(create().select(sha1(MESSAGE)).fetchOne(0));
|
||||
assertNotNull(create().select(sha2(MESSAGE, 256)).fetchOne(0));
|
||||
assertEquals(MESSAGE, create().select(decode(encode(MESSAGE, SECRET), val(SECRET))).fetchOne(0));
|
||||
assertEquals(MESSAGE, create().select(aesDecrypt(aesEncrypt(MESSAGE, SECRET), val(SECRET))).fetchOne(0));
|
||||
assertEquals(MESSAGE, create().select(desDecrypt(desEncrypt(MESSAGE, SECRET), val(SECRET))).fetchOne(0));
|
||||
assertEquals(MESSAGE, create().select(desDecrypt(desEncrypt(MESSAGE))).fetchOne(0));
|
||||
assertEquals(MESSAGE, create().select(uncompress(compress(MESSAGE))).fetchOne(0));
|
||||
assertEquals(3, create().select(uncompressedLength(compress(MESSAGE))).fetchOne(0));
|
||||
assertArrayEquals(MESSAGE, create().select(decode(encode(MESSAGE, SECRET), val(SECRET))).fetchOne().value1());
|
||||
assertArrayEquals(MESSAGE, create().select(aesDecrypt(aesEncrypt(MESSAGE, SECRET), val(SECRET))).fetchOne().value1());
|
||||
assertArrayEquals(MESSAGE, create().select(desDecrypt(desEncrypt(MESSAGE, SECRET), val(SECRET))).fetchOne().value1());
|
||||
assertArrayEquals(MESSAGE, create().select(desDecrypt(desEncrypt(MESSAGE))).fetchOne().value1());
|
||||
assertArrayEquals(MESSAGE, create().select(uncompress(compress(MESSAGE))).fetchOne().value1());
|
||||
assertEquals(5, create().select(uncompressedLength(compress(MESSAGE))).fetchOne(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@ -44,7 +44,6 @@ import org.jooq.EnumType;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.impl.DSL;
|
||||
import static org.jooq.impl.DSL.val;
|
||||
|
||||
/**
|
||||
* The {@link SQLDialect#MYSQL} specific DSL.
|
||||
@ -64,7 +63,7 @@ public class MySQLDSL extends DSL {
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>DECODE()</code> function
|
||||
* Get the MySQL-specific <code>DECODE()</code> function.
|
||||
* <p>
|
||||
* Don't mix this up with the various {@link DSL#decode()} methods!
|
||||
*/
|
||||
@ -73,7 +72,7 @@ public class MySQLDSL extends DSL {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>DECODE()</code> function
|
||||
* Get the MySQL-specific <code>DECODE()</code> function.
|
||||
* <p>
|
||||
* Don't mix this up with the various {@link DSL#decode()} methods!
|
||||
*/
|
||||
@ -82,7 +81,7 @@ public class MySQLDSL extends DSL {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>DECODE()</code> function
|
||||
* Get the MySQL-specific <code>DECODE()</code> function.
|
||||
* <p>
|
||||
* Don't mix this up with the various {@link DSL#decode()} methods!
|
||||
*/
|
||||
@ -91,274 +90,273 @@ public class MySQLDSL extends DSL {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>ENCODE()</code> function
|
||||
* Get the MySQL-specific <code>ENCODE()</code> function.
|
||||
*/
|
||||
public static Field<String> encode(String string, String keyString) {
|
||||
return encode(val(string), val(keyString));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>ENCODE()</code> function
|
||||
* Get the MySQL-specific <code>ENCODE()</code> function.
|
||||
*/
|
||||
public static Field<byte[]> encode(byte[] string, byte[] keyString) {
|
||||
return encode(val(string), val(keyString));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>ENCODE()</code> function
|
||||
* Get the MySQL-specific <code>ENCODE()</code> function.
|
||||
*/
|
||||
public static <T> Field<T> encode(Field<T> string, Field<T> keyString) {
|
||||
return function("encode", string.getType(), string, keyString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>AES_DECRYPT()</code> function
|
||||
* Get the MySQL-specific <code>AES_DECRYPT()</code> function.
|
||||
*/
|
||||
public static Field<String> aesDecrypt(String cryptString, String keyString) {
|
||||
return aesDecrypt(val(cryptString), val(keyString));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>AES_DECRYPT()</code> function
|
||||
* Get the MySQL-specific <code>AES_DECRYPT()</code> function.
|
||||
*/
|
||||
public static Field<byte[]> aesDecrypt(byte[] cryptString, byte[] keyString) {
|
||||
return aesDecrypt(val(cryptString), val(keyString));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>AES_DECRYPT()</code> function
|
||||
* Get the MySQL-specific <code>AES_DECRYPT()</code> function.
|
||||
*/
|
||||
public static <T> Field<T> aesDecrypt(Field<T> cryptString, Field<T> keyString) {
|
||||
return function("aes_decrypt", cryptString.getType(), cryptString, keyString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>AES_ENCRYPT()</code> function
|
||||
* Get the MySQL-specific <code>AES_ENCRYPT()</code> function.
|
||||
*/
|
||||
public static Field<String> aesEncrypt(String string, String keyString) {
|
||||
return aesEncrypt(val(string), val(keyString));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>AES_ENCRYPT()</code> function
|
||||
* Get the MySQL-specific <code>AES_ENCRYPT()</code> function.
|
||||
*/
|
||||
public static Field<byte[]> aesEncrypt(byte[] string, byte[] keyString) {
|
||||
return aesEncrypt(val(string), val(keyString));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>AES_ENCRYPT()</code> function
|
||||
* Get the MySQL-specific <code>AES_ENCRYPT()</code> function.
|
||||
*/
|
||||
public static <T> Field<T> aesEncrypt(Field<T> string, Field<T> keyString) {
|
||||
return function("aes_encrypt", string.getType(), string, keyString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>DES_DECRYPT()</code> function
|
||||
* Get the MySQL-specific <code>DES_DECRYPT()</code> function.
|
||||
*/
|
||||
public static Field<String> desDecrypt(String cryptString) {
|
||||
return desDecrypt(val(cryptString));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>DES_DECRYPT()</code> function
|
||||
* Get the MySQL-specific <code>DES_DECRYPT()</code> function.
|
||||
*/
|
||||
public static Field<byte[]> desDecrypt(byte[] cryptString) {
|
||||
return desDecrypt(val(cryptString));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>DES_DECRYPT()</code> function
|
||||
* Get the MySQL-specific <code>DES_DECRYPT()</code> function.
|
||||
*/
|
||||
public static <T> Field<T> desDecrypt(Field<T> cryptString) {
|
||||
return function("des_decrypt", cryptString.getType(), cryptString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>DES_DECRYPT()</code> function
|
||||
* Get the MySQL-specific <code>DES_DECRYPT()</code> function.
|
||||
*/
|
||||
public static Field<String> desDecrypt(String cryptString, String keyString) {
|
||||
return desDecrypt(val(cryptString), val(keyString));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>DES_DECRYPT()</code> function
|
||||
* Get the MySQL-specific <code>DES_DECRYPT()</code> function.
|
||||
*/
|
||||
public static Field<byte[]> desDecrypt(byte[] cryptString, byte[] keyString) {
|
||||
return desDecrypt(val(cryptString), val(keyString));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>DES_DECRYPT()</code> function
|
||||
* Get the MySQL-specific <code>DES_DECRYPT()</code> function.
|
||||
*/
|
||||
public static <T> Field<T> desDecrypt(Field<T> cryptString, Field<T> keyString) {
|
||||
return function("des_decrypt", cryptString.getType(), cryptString, keyString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>DES_ENCRYPT()</code> function
|
||||
* Get the MySQL-specific <code>DES_ENCRYPT()</code> function.
|
||||
*/
|
||||
public static Field<String> desEncrypt(String string) {
|
||||
return desEncrypt(val(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>DES_ENCRYPT()</code> function
|
||||
* Get the MySQL-specific <code>DES_ENCRYPT()</code> function.
|
||||
*/
|
||||
public static Field<byte[]> desEncrypt(byte[] string) {
|
||||
return desEncrypt(val(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>DES_ENCRYPT()</code> function
|
||||
* Get the MySQL-specific <code>DES_ENCRYPT()</code> function.
|
||||
*/
|
||||
public static <T> Field<T> desEncrypt(Field<T> string) {
|
||||
return function("des_encrypt", string.getType(), string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>DES_ENCRYPT()</code> function
|
||||
* Get the MySQL-specific <code>DES_ENCRYPT()</code> function.
|
||||
*/
|
||||
public static Field<String> desEncrypt(String string, String keyString) {
|
||||
return desEncrypt(val(string), val(keyString));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>DES_ENCRYPT()</code> function
|
||||
* Get the MySQL-specific <code>DES_ENCRYPT()</code> function.
|
||||
*/
|
||||
public static Field<byte[]> desEncrypt(byte[] string, byte[] keyString) {
|
||||
return desEncrypt(val(string), val(keyString));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>DES_ENCRYPT()</code> function
|
||||
* Get the MySQL-specific <code>DES_ENCRYPT()</code> function.
|
||||
*/
|
||||
public static <T> Field<T> desEncrypt(Field<T> string, Field<T> keyString) {
|
||||
return function("des_encrypt", string.getType(), string, keyString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>COMPRESS()</code> function
|
||||
* Get the MySQL-specific <code>COMPRESS()</code> function.
|
||||
*/
|
||||
public static Field<String> compress(String string) {
|
||||
return compress(val(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>COMPRESS()</code> function
|
||||
* Get the MySQL-specific <code>COMPRESS()</code> function.
|
||||
*/
|
||||
public static Field<byte[]> compress(byte[] string) {
|
||||
return compress(val(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>COMPRESS()</code> function
|
||||
* Get the MySQL-specific <code>COMPRESS()</code> function.
|
||||
*/
|
||||
public static <T> Field<T> compress(Field<T> string) {
|
||||
return function("compress", string.getType(), string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>UNCOMPRESS()</code> function
|
||||
* Get the MySQL-specific <code>UNCOMPRESS()</code> function.
|
||||
*/
|
||||
public static Field<String> uncompress(String string) {
|
||||
return uncompress(val(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>UNCOMPRESS()</code> function
|
||||
* Get the MySQL-specific <code>UNCOMPRESS()</code> function.
|
||||
*/
|
||||
public static Field<byte[]> uncompress(byte[] string) {
|
||||
return uncompress(val(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>UNCOMPRESS()</code> function
|
||||
* Get the MySQL-specific <code>UNCOMPRESS()</code> function.
|
||||
*/
|
||||
public static <T> Field<T> uncompress(Field<T> string) {
|
||||
return function("uncompress", string.getType(), string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>UNCOMPRESSED_LENGTH()</code> function
|
||||
* Get the MySQL-specific <code>UNCOMPRESSED_LENGTH()</code> function.
|
||||
*/
|
||||
public static Field<Integer> uncompressedLength(String string) {
|
||||
return uncompressedLength(val(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>UNCOMPRESSED_LENGTH()</code> function
|
||||
* Get the MySQL-specific <code>UNCOMPRESSED_LENGTH()</code> function.
|
||||
*/
|
||||
public static Field<Integer> uncompressedLength(byte[] string) {
|
||||
return uncompressedLength(val(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>UNCOMPRESSED_LENGTH()</code> function
|
||||
* Get the MySQL-specific <code>UNCOMPRESSED_LENGTH()</code> function.
|
||||
*/
|
||||
public static <T> Field<Integer> uncompressedLength(Field<T> string) {
|
||||
return function("uncompressed_length", Integer.class, string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>SHA1()</code> function
|
||||
* Get the MySQL-specific <code>SHA1()</code> function.
|
||||
*/
|
||||
public static Field<String> sha1(String string) {
|
||||
return sha1(val(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>SHA1()</code> function
|
||||
* Get the MySQL-specific <code>SHA1()</code> function.
|
||||
*/
|
||||
public static Field<byte[]> sha1(byte[] string) {
|
||||
return sha1(val(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>SHA1()</code> function
|
||||
* Get the MySQL-specific <code>SHA1()</code> function.
|
||||
*/
|
||||
public static <T> Field<T> sha1(Field<T> string) {
|
||||
return function("sha1", string.getType(), string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>SHA2()</code> function
|
||||
* Get the MySQL-specific <code>SHA2()</code> function.
|
||||
*/
|
||||
public static Field<String> sha2(String string, int hashLength) {
|
||||
return sha2(val(string), val(hashLength));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>SHA2()</code> function
|
||||
* Get the MySQL-specific <code>SHA2()</code> function.
|
||||
*/
|
||||
public static Field<byte[]> sha2(byte[] string, int hashLength) {
|
||||
return sha2(val(string), val(hashLength));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>SHA2()</code> function
|
||||
* Get the MySQL-specific <code>SHA2()</code> function.
|
||||
*/
|
||||
public static <T> Field<T> sha2(Field<T> string, Field<Integer> hashLength) {
|
||||
return function("sha2", string.getType(), string, hashLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>PASSWORD()</code> function
|
||||
* Get the MySQL-specific <code>PASSWORD()</code> function.
|
||||
*/
|
||||
public static Field<String> password(String string) {
|
||||
return password(val(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>PASSWORD()</code> function
|
||||
* Get the MySQL-specific <code>PASSWORD()</code> function.
|
||||
*/
|
||||
public static Field<byte[]> password(byte[] string) {
|
||||
return password(val(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>PASSWORD()</code> function
|
||||
* Get the MySQL-specific <code>PASSWORD()</code> function.
|
||||
*/
|
||||
public static <T> Field<T> password(Field<T> string) {
|
||||
return function("password", string.getType(), string);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user