forked from github/dataease
fix: pg 时间类型转换
This commit is contained in:
parent
d0e079b50c
commit
9fa66031e8
@ -19,8 +19,6 @@ public class PgConstants extends SQLConstants {
|
||||
|
||||
public static final String FROM_UNIXTIME = "to_timestamp(%s)";
|
||||
|
||||
public static final String TO_DATE = "to_date(%s,'%s')";
|
||||
|
||||
public static final String CAST = "CAST(%s AS %s)";
|
||||
|
||||
public static final String DEFAULT_DATE_FORMAT = "YYYY-MM-DD HH24:MI:SS";
|
||||
|
@ -790,7 +790,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
}
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(PgConstants.TO_DATE, originName, PgConstants.DEFAULT_DATE_FORMAT);
|
||||
whereName = String.format(PgConstants.CAST, originName, "timestamp");
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(PgConstants.CAST, originName, "bigint");
|
||||
@ -854,7 +854,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(PgConstants.TO_DATE, originName, PgConstants.DEFAULT_DATE_FORMAT);
|
||||
whereName = String.format(PgConstants.CAST, originName, "timestamp");
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(PgConstants.CAST, originName, "bigint");
|
||||
@ -945,7 +945,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
if (x.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
String format = transDateFormat(x.getDateStyle(), x.getDatePattern());
|
||||
if (x.getDeExtractType() == DeTypeConstants.DE_STRING) {
|
||||
fieldName = String.format(PgConstants.DATE_FORMAT, String.format(PgConstants.TO_DATE, originField, "YYYY-MM-DD HH24:MI:SS"), format);
|
||||
fieldName = String.format(PgConstants.DATE_FORMAT, String.format(PgConstants.CAST, originField, "timestamp"), format);
|
||||
} else {
|
||||
String cast = String.format(PgConstants.CAST, originField, "bigint");
|
||||
String from_unixtime = String.format(PgConstants.FROM_UNIXTIME, cast);
|
||||
|
@ -727,7 +727,7 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
}
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(PgConstants.TO_DATE, originName, PgConstants.DEFAULT_DATE_FORMAT);
|
||||
whereName = String.format(PgConstants.CAST, originName, "timestamp");
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(PgConstants.CAST, originName, "bigint");
|
||||
@ -785,7 +785,7 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(PgConstants.TO_DATE, originName, PgConstants.DEFAULT_DATE_FORMAT);
|
||||
whereName = String.format(PgConstants.CAST, originName, "timestamp");
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(PgConstants.CAST, originName, "bigint");
|
||||
|
Loading…
Reference in New Issue
Block a user