Skip to content

Commit f18cc3d

Browse files
committed
Merge branch '7.0' into 7.1
# Conflicts: # core/.classpath # loader/build.xml # loader/pom.xml # test/tickets/LDEV2423.cfc # test/tickets/LDEV3022.cfc
2 parents 2efe970 + 23727bd commit f18cc3d

18 files changed

Lines changed: 341 additions & 23 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ target/*
2121
WEB-INF
2222
core/bin/
2323
loader/bin/
24-
.classpath
24+
/.classpath
2525
*.eml
2626
*.iml
2727
*.ipr

core/src/main/java/lucee/commons/io/res/type/file/FileResource.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ public void copyTo(Resource res, boolean append) throws IOException {
131131
}
132132

133133
/**
134-
* LDEV-6095: after copy, ensure the owner can read/write the new file without altering group/other bits
135-
* (ModeUtil-based setReadable/setWritable would set all roles and break mode preservation).
134+
* LDEV-6095: after copy, ensure the owner can read/write the new file without altering group/other
135+
* bits (ModeUtil-based setReadable/setWritable would set all roles and break mode preservation).
136136
* When {@code attributeCopyUsed} is true, {@link StandardCopyOption#COPY_ATTRIBUTES} already copied
137137
* readonly/hidden/etc.; only add missing owner write when the POSIX mode lacks it (e.g. chmod 444).
138-
* Readonly set via {@link #setWritable(boolean)} is tracked with a user xattr so it can be distinguished
139-
* from a plain {@code fileSetAccessMode} change during copy.
138+
* Readonly set via {@link #setWritable(boolean)} is tracked with a user xattr so it can be
139+
* distinguished from a plain {@code fileSetAccessMode} change during copy.
140140
*/
141141
private static void applyPermissionsAfterCopy(Resource dest, Resource source, boolean attributeCopyUsed) {
142142
if (dest instanceof FileResource) {
@@ -278,7 +278,7 @@ private static boolean hasReadonlyAttribute(Path path) {
278278
try {
279279
UserDefinedFileAttributeView view = Files.getFileAttributeView(path, UserDefinedFileAttributeView.class);
280280
if (view == null || !view.list().contains(READONLY_ATTRIBUTE)) return false;
281-
int size = (int) view.size(READONLY_ATTRIBUTE);
281+
int size = view.size(READONLY_ATTRIBUTE);
282282
ByteBuffer buf = ByteBuffer.allocate(size);
283283
view.read(READONLY_ATTRIBUTE, buf);
284284
buf.flip();
@@ -663,8 +663,7 @@ public boolean renameTo(Resource dest) {
663663
moveTo(dest);
664664
return true;
665665
}
666-
catch (IOException e) {
667-
}
666+
catch (IOException e) {}
668667
return false;
669668
}
670669

@@ -880,8 +879,7 @@ public boolean exists() {
880879
try {
881880
provider.read(this);
882881
}
883-
catch (IOException e) {
884-
}
882+
catch (IOException e) {}
885883

886884
return super.exists();
887885
}

core/src/main/java/lucee/runtime/db/SQLCaster.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public static void setValue(PageContext pc, TimeZone tz, PreparedStatement stat,
250250
case Types.DOUBLE:
251251
case Types.FLOAT:
252252
try {
253-
if (type == Types.FLOAT) stat.setFloat(parameterIndex, Caster.toFloatValue(value));
253+
if (type == Types.FLOAT) stat.setDouble(parameterIndex, Caster.toDoubleValue(value));
254254
else if (type == Types.DOUBLE) stat.setDouble(parameterIndex, Caster.toDoubleValue(value));
255255
else stat.setObject(parameterIndex, Caster.toDouble(value), type);
256256
}

core/src/main/java/lucee/runtime/query/caster/Cast.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,15 @@
2424
import java.util.Calendar;
2525
import java.util.TimeZone;
2626

27+
import lucee.commons.io.SystemUtil;
28+
import lucee.runtime.op.Caster;
29+
2730
public interface Cast {
2831

32+
// when enabled, DATE/TIME/TIMESTAMP query columns keep the JDBC driver's native toString() format
33+
// (matching ACF) instead of Lucee's {ts '...'} ODBC escape format when cast to a string - see LDEV-1344
34+
public static final boolean JDBC_DATETIME_FORMAT = Caster.toBooleanValue(SystemUtil.getSystemPropOrEnvVar("lucee.query.datetime.jdbcformat", null), false);
35+
2936
public static final Cast ARRAY = new ArrayCast();
3037
public static final Cast BIT = new BitCast();
3138
public static final Cast BLOB = new BlobCast();

core/src/main/java/lucee/runtime/query/caster/DateCast.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import lucee.commons.date.JREDateTimeUtil;
2929
import lucee.runtime.type.dt.DateTimeImpl;
30+
import lucee.runtime.type.dt.TimestampImpl;
3031

3132
public final class DateCast implements Cast {
3233

@@ -40,7 +41,7 @@ public DateCast(boolean useTimeZone) {
4041
public Object toCFType(TimeZone tz, ResultSet rst, int columnIndex) throws SQLException, IOException {
4142
Date d = useTimeZone ? rst.getDate(columnIndex, JREDateTimeUtil.getThreadCalendar(tz)) : rst.getDate(columnIndex);
4243
if (d == null) return null;
43-
return new DateTimeImpl(d.getTime());
44+
return Cast.JDBC_DATETIME_FORMAT ? new TimestampImpl(d, d.toString()) : new DateTimeImpl(d.getTime());
4445

4546
}
4647

core/src/main/java/lucee/runtime/query/caster/OracleTimestampLTZ.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import lucee.runtime.exp.PageException;
2828
import lucee.runtime.reflection.Reflector;
2929
import lucee.runtime.type.dt.DateTimeImpl;
30+
import lucee.runtime.type.dt.TimestampImpl;
3031

3132
public final class OracleTimestampLTZ implements Cast {
3233

@@ -38,7 +39,7 @@ public Object toCFType(TimeZone tz, ResultSet rst, int columnIndex) throws SQLEx
3839
// we do not have oracle.sql.TIMESTAMPTZ in the core, so we need reflection for this
3940
try {
4041
Timestamp ts = (Timestamp) Reflector.callMethod(o, "timestampValue", new Object[] { rst.getStatement().getConnection(), JREDateTimeUtil.getThreadCalendar(tz) });
41-
return new DateTimeImpl(ts.getTime());
42+
return Cast.JDBC_DATETIME_FORMAT ? new TimestampImpl(ts, ts.toString()) : new DateTimeImpl(ts.getTime());
4243
}
4344
catch (PageException pe) {
4445
throw ExceptionUtil.toIOException(pe);

core/src/main/java/lucee/runtime/query/caster/OracleTimestampNS.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import lucee.runtime.exp.PageException;
2727
import lucee.runtime.reflection.Reflector;
2828
import lucee.runtime.type.dt.DateTimeImpl;
29+
import lucee.runtime.type.dt.TimestampImpl;
2930

3031
public final class OracleTimestampNS implements Cast {
3132

@@ -37,7 +38,7 @@ public Object toCFType(TimeZone tz, ResultSet rst, int columnIndex) throws SQLEx
3738
// we do not have oracle.sql.TIMESTAMPTZ in the core, so we need reflection for this
3839
try {
3940
Timestamp ts = (Timestamp) Reflector.callMethod(o, "timestampValue", new Object[] {});
40-
return new DateTimeImpl(ts.getTime());
41+
return Cast.JDBC_DATETIME_FORMAT ? new TimestampImpl(ts, ts.toString()) : new DateTimeImpl(ts.getTime());
4142
}
4243
catch (PageException pe) {
4344
throw ExceptionUtil.toIOException(pe);

core/src/main/java/lucee/runtime/query/caster/OracleTimestampTZ.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import lucee.runtime.exp.PageException;
2727
import lucee.runtime.reflection.Reflector;
2828
import lucee.runtime.type.dt.DateTimeImpl;
29+
import lucee.runtime.type.dt.TimestampImpl;
2930

3031
public final class OracleTimestampTZ implements Cast {
3132

@@ -37,7 +38,7 @@ public Object toCFType(TimeZone tz, ResultSet rst, int columnIndex) throws SQLEx
3738
// we do not have oracle.sql.TIMESTAMPTZ in the core, so we need reflection for this
3839
try {
3940
Timestamp ts = (Timestamp) Reflector.callMethod(o, "timestampValue", new Object[] { rst.getStatement().getConnection() });
40-
return new DateTimeImpl(ts.getTime());
41+
return Cast.JDBC_DATETIME_FORMAT ? new TimestampImpl(ts, ts.toString()) : new DateTimeImpl(ts.getTime());
4142
}
4243
catch (PageException pe) {
4344
throw ExceptionUtil.toIOException(pe);

core/src/main/java/lucee/runtime/query/caster/TimeCast.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import lucee.commons.date.JREDateTimeUtil;
2929
import lucee.runtime.type.dt.DateTimeImpl;
30+
import lucee.runtime.type.dt.TimestampImpl;
3031

3132
public final class TimeCast implements Cast {
3233

@@ -41,7 +42,7 @@ public Object toCFType(TimeZone tz, ResultSet rst, int columnIndex) throws SQLEx
4142
Time t = useTimeZone ? rst.getTime(columnIndex, JREDateTimeUtil.getThreadCalendar(tz)) : rst.getTime(columnIndex);
4243
if (t == null) return null;
4344

44-
return new DateTimeImpl(t.getTime());
45+
return Cast.JDBC_DATETIME_FORMAT ? new TimestampImpl(t, t.toString()) : new DateTimeImpl(t.getTime());
4546

4647
}
4748

core/src/main/java/lucee/runtime/query/caster/TimestampCast.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import lucee.commons.date.JREDateTimeUtil;
2929
import lucee.runtime.type.dt.DateTimeImpl;
30+
import lucee.runtime.type.dt.TimestampImpl;
3031

3132
public final class TimestampCast implements Cast {
3233

@@ -40,7 +41,7 @@ public TimestampCast(boolean useTimeZone) {
4041
public Object toCFType(TimeZone tz, ResultSet rst, int columnIndex) throws SQLException, IOException {
4142
Timestamp ts = useTimeZone ? rst.getTimestamp(columnIndex, JREDateTimeUtil.getThreadCalendar(tz)) : rst.getTimestamp(columnIndex);
4243
if (ts == null) return null;
43-
return new DateTimeImpl(ts.getTime());
44+
return Cast.JDBC_DATETIME_FORMAT ? new TimestampImpl(ts, ts.toString()) : new DateTimeImpl(ts.getTime());
4445
}
4546

4647
@Override

0 commit comments

Comments
 (0)