connectivity/source/commontools/dbtools2.cxx             |   29 ++-
 connectivity/source/commontools/formattedcolumnvalue.cxx |    2 
 dbaccess/source/ui/tabledesign/FieldDescriptions.cxx     |    3 
 offapi/com/sun/star/sdbc/DataType.idl                    |  130 +++++++++++----
 4 files changed, 125 insertions(+), 39 deletions(-)

New commits:
commit 5b205d2b3946acd79dcb8f5abed88a0bd8afaef4
Author:     Pierre <prrv...@gmail.com>
AuthorDate: Sun Aug 20 00:22:58 2023 +0200
Commit:     Julien Nabet <serval2...@yahoo.fr>
CommitDate: Thu Aug 31 20:28:50 2023 +0200

    tdf#156816 Base handles scale on SQL type TIME as with TIMESTAMP
    
    Generally import new DataType identification constants from OpenJDK's
    java.sql.Types
    Use same values for compatibility.
    
    Change-Id: I6e3eb986dc34e8a5e2af75669363177785ff56e5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155866
    Reviewed-by: Lionel Mamane <lio...@mamane.lu>
    Tested-by: Julien Nabet <serval2...@yahoo.fr>

diff --git a/connectivity/source/commontools/dbtools2.cxx 
b/connectivity/source/commontools/dbtools2.cxx
index 2cee15cd7f6a..fc533d0ff024 100644
--- a/connectivity/source/commontools/dbtools2.cxx
+++ b/connectivity/source/commontools/dbtools2.cxx
@@ -127,30 +127,39 @@ OUString createStandardTypePart(const Reference< 
XPropertySet >& xColProp,const
 
     if ( (nPrecision > 0 || nScale > 0) && bUseLiteral )
     {
-        sal_Int32 nParenPos = sTypeName.indexOf('(');
+        bool bTimed = (nDataType == DataType::TIME ||
+                       nDataType == DataType::TIME_WITH_TIMEZONE ||
+                       nDataType == DataType::TIMESTAMP ||
+                       nDataType == DataType::TIMESTAMP_WITH_TIMEZONE);
+
+        sal_Int32 nParenPos = (nDataType == DataType::TIME_WITH_TIMEZONE ||
+                               nDataType == DataType::TIMESTAMP_WITH_TIMEZONE) 
?
+                               sTypeName.indexOf(' ') :
+                               sTypeName.indexOf('(');
+
         if ( nParenPos == -1 )
-        {
-            aSql.append(sTypeName + "(");
-        }
+            aSql.append(sTypeName);
         else
-        {
-            aSql.append(sTypeName.subView(0, ++nParenPos));
-        }
+            aSql.append(sTypeName.subView(0, nParenPos));
+        aSql.append("(");
 
-        if ( nPrecision > 0 && nDataType != DataType::TIMESTAMP )
+        if ( nPrecision > 0 && !bTimed )
         {
             aSql.append(nPrecision);
             if ( (nScale > 0) || (!_sCreatePattern.empty() && 
sCreateParams.indexOf(_sCreatePattern) != -1) )
                 aSql.append(",");
         }
-        if ( (nScale > 0) || ( !_sCreatePattern.empty() && 
sCreateParams.indexOf(_sCreatePattern) != -1 ) || nDataType == 
DataType::TIMESTAMP )
+        if ( (nScale > 0) || ( !_sCreatePattern.empty() && 
sCreateParams.indexOf(_sCreatePattern) != -1 ) || bTimed )
             aSql.append(nScale);
 
         if ( nParenPos == -1 )
             aSql.append(")");
         else
         {
-            nParenPos = sTypeName.indexOf(')',nParenPos);
+            if ( bTimed )
+                aSql.append(")");
+            else
+                nParenPos = sTypeName.indexOf(')',nParenPos);
             aSql.append(sTypeName.subView(nParenPos));
         }
     }
diff --git a/connectivity/source/commontools/formattedcolumnvalue.cxx 
b/connectivity/source/commontools/formattedcolumnvalue.cxx
index 621bc9acf59b..a389236e6aa0 100644
--- a/connectivity/source/commontools/formattedcolumnvalue.cxx
+++ b/connectivity/source/commontools/formattedcolumnvalue.cxx
@@ -126,7 +126,9 @@ namespace dbtools
                 {
                     case DataType::DATE:
                     case DataType::TIME:
+                    case DataType::TIME_WITH_TIMEZONE:
                     case DataType::TIMESTAMP:
+                    case DataType::TIMESTAMP_WITH_TIMEZONE:
                     case DataType::BIT:
                     case DataType::BOOLEAN:
                     case DataType::TINYINT:
diff --git a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx 
b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
index a8efb638a7bd..4a4a499380a9 100644
--- a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
+++ b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
@@ -187,7 +187,10 @@ void OFieldDescription::FillFromTypeInfo(const 
TOTypeInfoSP& _pType,bool _bForce
                 SetPrecision(std::min<sal_Int32>(nPrec,_pType->nPrecision));
             }
             break;
+        case DataType::TIME:
+        case DataType::TIME_WITH_TIMEZONE:
         case DataType::TIMESTAMP:
+        case DataType::TIMESTAMP_WITH_TIMEZONE:
             if ( bForce && _pType->nMaximumScale)
             {
                 SetScale(std::min<sal_Int32>(GetScale() ? GetScale() : 
DEFAULT_NUMERIC_SCALE,_pType->nMaximumScale));
diff --git a/offapi/com/sun/star/sdbc/DataType.idl 
b/offapi/com/sun/star/sdbc/DataType.idl
index 12cfa4f9395c..375a76f30a86 100644
--- a/offapi/com/sun/star/sdbc/DataType.idl
+++ b/offapi/com/sun/star/sdbc/DataType.idl
@@ -33,97 +33,169 @@
  */
 published constants DataType
 {
-    const long BIT          =  -7;
+    const long BIT                        =   -7;
 
-    const long TINYINT      =  -6;
+    const long TINYINT                    =   -6;
 
-    const long SMALLINT     =   5;
+    const long SMALLINT                   =    5;
 
-    const long INTEGER      =   4;
+    const long INTEGER                    =    4;
 
-    const long BIGINT       =  -5;
+    const long BIGINT                     =   -5;
 
-    const long FLOAT        =   6;
+    const long FLOAT                      =    6;
 
-    const long REAL         =   7;
+    const long REAL                       =    7;
 
-    const long DOUBLE       =   8;
+    const long DOUBLE                     =    8;
 
-    const long NUMERIC      =   2;
+    const long NUMERIC                    =    2;
 
-    const long DECIMAL      =   3;
+    const long DECIMAL                    =    3;
 
-    const long CHAR         =   1;
+    const long CHAR                       =    1;
 
-    const long VARCHAR      =  12;
+    const long VARCHAR                    =   12;
 
-    const long LONGVARCHAR  =  -1;
+    const long LONGVARCHAR                =   -1;
 
-    const long DATE         =  91;
+    const long DATE                       =   91;
 
-    const long TIME         =  92;
+    const long TIME                       =   92;
 
-    const long TIMESTAMP    =  93;
+    const long TIMESTAMP                  =   93;
 
-    const long BINARY       =  -2;
+    const long BINARY                     =   -2;
 
-    const long VARBINARY    =  -3;
+    const long VARBINARY                  =   -3;
 
-    const long LONGVARBINARY =  -4;
+    const long LONGVARBINARY              =   -4;
 
-    const long SQLNULL      =   0;
+    const long SQLNULL                    =    0;
 
 
     /** indicates that the SQL type is database-specific and
              gets mapped to an object that can be accessed via
              the method com::sun::star::sdbc::XRow::getObject().
      */
-    const long OTHER        = 1111;
+    const long OTHER                      = 1111;
 
 
     /** indicates a type which is represented by an object which implements
              this type.
      */
-    const long OBJECT        = 2000;
+    const long OBJECT                     = 2000;
 
 
     /** describes a type based on a built-in type.
                  It is a user-defined data type (UDT).
      */
-    const long DISTINCT     = 2001;
+    const long DISTINCT                   = 2001;
 
 
     /** indicates a type consisting of attributes that may be any type.
                  It is a user-defined data type (UDT).
      */
-    const long STRUCT       = 2002;
+    const long STRUCT                     = 2002;
 
 
     /** indicates a type representing an SQL ARRAY.
      */
-    const long ARRAY        = 2003;
+    const long ARRAY                      = 2003;
 
 
     /** indicates a type representing an SQL Binary Large Object.
      */
-    const long BLOB         = 2004;
+    const long BLOB                       = 2004;
 
 
     /** indicates a type representing an SQL Character Large Object.
      */
-    const long CLOB         = 2005;
+    const long CLOB                       = 2005;
 
 
     /** indicates a type representing an SQL REF, a referencing type.
      */
-    const long REF          = 2006;
+    const long REF                        = 2006;
+
 
     /** identifies the generic SQL type
      * <code>BOOLEAN</code>.
      *
      * @since OOo 2.0
      */
-    const long BOOLEAN = 16;
+    const long BOOLEAN                    =   16;
+
+
+    /** indicates a type representing an SQL DATALINK.
+     *
+     * @since LO 24.02
+     */
+    const long DATALINK                   =   70;
+
+
+    /** indicates a type representing an SQL ROWID.
+     *
+     * @since LO 24.02
+     */
+    const long ROWID                      =   -8;
+
+
+    /** indicates a type representing an SQL NCHAR.
+     *
+     * @since LO 24.02
+     */
+    const long NCHAR                      =  -15;
+
+
+    /** indicates a type representing an SQL NVARCHAR.
+     *
+     * @since LO 24.02
+     */
+    const long NVARCHAR                   =   -9;
+
+
+    /** indicates a type representing an SQL LONGNVARCHAR.
+     *
+     * @since LO 24.02
+     */
+    const long LONGNVARCHAR               =  -16;
+
+
+    /** indicates a type representing an SQL NCLOB.
+     *
+     * @since LO 24.02
+     */
+    const long NCLOB                      = 2011;
+
+
+    /** indicates a type representing an SQL XML.
+     *
+     * @since LO 24.02
+     */
+    const long SQLXML                     = 2009;
+
+
+    /** indicates a type representing an SQL REF CURSOR.
+     *
+     * @since LO 24.02
+     */
+    const long REF_CURSOR                 = 2012;
+
+
+    /** indicates a type representing an SQL TIME WITH TIMEZONE.
+     *
+     * @since LO 24.02
+     */
+    const long TIME_WITH_TIMEZONE         = 2013;
+
+
+    /** indicates a type representing an SQL TIMESTAMP WITH TIMEZONE.
+     *
+     * @since LO 24.02
+     */
+    const long TIMESTAMP_WITH_TIMEZONE    = 2014;
+
 };
 
 

Reply via email to