[jOOQ/jOOQ#11061] [jOOQ/jOOQ#11070] [jOOQ/jOOQ#11091] MD5
This commit is contained in:
parent
c131c7cb88
commit
9c7aca81ea
@ -15216,6 +15216,24 @@ public class DSL {
|
||||
return new Ltrim(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>MD5</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
public static Field<String> md5(String string) {
|
||||
return new Md5(Tools.field(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>MD5</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
public static Field<String> md5(Field<String> string) {
|
||||
return new Md5(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>MID</code> function, an alias for the <code>SUBSTRING</code> function.
|
||||
*/
|
||||
@ -16156,78 +16174,6 @@ public class DSL {
|
||||
return new Concat(Tools.nullSafe(fields));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// XXX Hash function factory
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>MD5()</code> function.
|
||||
* <p>
|
||||
* These are the implementations for various databases:
|
||||
* <p>
|
||||
* <table border="1">
|
||||
* <tr>
|
||||
* <th>Database</th>
|
||||
* <th>Implementation</th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MySQL</td>
|
||||
* <td><code>MD5( ... )</code></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Oracle 11g</td>
|
||||
* <td>
|
||||
* <code>LOWER(RAWTOHEX(SYS.DBMS_CRYPTO.HASH(UTL_RAW.CAST_TO_RAW( ... ), SYS.DBMS_CRYPTO.HASH_MD5)))</code>
|
||||
* </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Oracle 12c</td>
|
||||
* <td>
|
||||
* <code>LOWER(STANDARD_HASH( ... , 'MD5'))</code>
|
||||
* </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<String> md5(String string) {
|
||||
return md5(Tools.field(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MySQL-specific <code>MD5()</code> function.
|
||||
* <p>
|
||||
* These are the implementations for various databases:
|
||||
* <p>
|
||||
* <table border="1">
|
||||
* <tr>
|
||||
* <th>Database</th>
|
||||
* <th>Implementation</th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MySQL</td>
|
||||
* <td><code>MD5( ... )</code></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Oracle 11g</td>
|
||||
* <td>
|
||||
* <code>LOWER(RAWTOHEX(SYS.DBMS_CRYPTO.HASH(UTL_RAW.CAST_TO_RAW( ... ), SYS.DBMS_CRYPTO.HASH_MD5)))</code>
|
||||
* </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Oracle 12c</td>
|
||||
* <td>
|
||||
* <code>LOWER(STANDARD_HASH( ... , 'MD5'))</code>
|
||||
* </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<String> md5(Field<String> string) {
|
||||
return new MD5(Tools.nullSafe(string));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// XXX Date and time functions
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@ -37,46 +37,56 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Keywords.K_VARCHAR;
|
||||
import static org.jooq.impl.Names.N_CONVERT;
|
||||
import static org.jooq.impl.Names.N_HASHBYTES;
|
||||
import static org.jooq.impl.Names.N_LOWER;
|
||||
import static org.jooq.impl.Names.N_MD5;
|
||||
import static org.jooq.impl.Names.N_RAWTOHEX;
|
||||
import static org.jooq.impl.Names.N_STANDARD_HASH;
|
||||
import static org.jooq.impl.SQLDataType.VARCHAR;
|
||||
import static org.jooq.impl.DSL.*;
|
||||
import static org.jooq.impl.Internal.*;
|
||||
import static org.jooq.impl.Keywords.*;
|
||||
import static org.jooq.impl.Names.*;
|
||||
import static org.jooq.impl.SQLDataType.*;
|
||||
import static org.jooq.impl.Tools.*;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.*;
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Name;
|
||||
// ...
|
||||
import org.jooq.*;
|
||||
import org.jooq.impl.*;
|
||||
// ...
|
||||
|
||||
import java.math.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
* The <code>MD5</code> statement.
|
||||
*/
|
||||
final class MD5 extends AbstractField<String> {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class Md5
|
||||
extends
|
||||
AbstractField<String>
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Field<String> string;
|
||||
|
||||
Md5(
|
||||
Field<String> string
|
||||
) {
|
||||
super(N_MD5, allNotNull(VARCHAR, string));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -7273879239726265322L;
|
||||
|
||||
private final Field<String> argument;
|
||||
|
||||
MD5(Field<String> argument) {
|
||||
super(N_MD5, VARCHAR);
|
||||
|
||||
this.argument = argument;
|
||||
this.string = nullSafeNotNull(string, VARCHAR);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.dialect()) {
|
||||
@ -105,8 +115,10 @@ final class MD5 extends AbstractField<String> {
|
||||
|
||||
|
||||
default:
|
||||
ctx.visit(N_MD5).sql('(').visit(argument).sql(')');
|
||||
ctx.visit(N_MD5).sql('(').visit(string).sql(')');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user