Project

General

Profile

7924-20231114.patch

Dănuț Filimon, 11/14/2023 07:07 AM

Download (4.67 KB)

View differences:

new/src/com/goldencode/p2j/persist/dialect/Dialect.java 2023-11-14 12:03:51 +0000
1024 1024
      {
1025 1025
         P2JIndexComponent comp = comps.get(i);
1026 1026
         String sortCrit;
1027
         if (comp.isCharType()/* && comp.isIgnoreCase()*/)
1027
         boolean isChar = comp.isCharType();
1028
         if (isChar/* && comp.isIgnoreCase()*/)
1028 1029
         {
1029 1030
            sortCrit = getProcessedCharacterColumnName(comp.getColumnName(), comp.isIgnoreCase());
1030 1031
         }
......
1033 1034
            sortCrit = comp.getColumnName();
1034 1035
         }
1035 1036
         
1036
         orderByNulls(sb, sortCrit, null, !comp.isDescending(), false);
1037
         orderByNulls(sb, sortCrit, null, !comp.isDescending(), false, isChar);
1037 1038
         
1038 1039
         if (i != comps.size() - 1)
1039 1040
         {
......
1491 1492
    *          The sort direction.
1492 1493
    * @param   forceAsc
1493 1494
    *          If {@code true}, force the insertion of the default {@code asc} direction.
1495
    * @param   isChar
1496
    *          {@code true} if the field is of type character, {@code false} otherwise.
1494 1497
    *
1495 1498
    * @return  the number of expressions which were added to the string builder.
1496 1499
    */
1497
   public int orderByNulls(StringBuilder sb, String expression, String field, boolean asc, boolean forceAsc)
1500
   public int orderByNulls(StringBuilder sb,
1501
                           String expression,
1502
                           String field,
1503
                           boolean asc,
1504
                           boolean forceAsc,
1505
                           boolean isChar)
1498 1506
   {
1499 1507
      sb.append(expression);
1500 1508
      if (!asc)
new/src/com/goldencode/p2j/persist/dialect/MariaDbDialect.java 2023-11-14 12:04:22 +0000
170 170
    *          The sort direction.
171 171
    * @param   forceAsc
172 172
    *          If {@code true}, force the insertion of the default {@code asc} direction.
173
    * @param   isChar
174
    *          {@code true} if the field is of type character, {@code false} otherwise.
173 175
    *
174 176
    * @return  the number of expressions which were added to the string builder.
175 177
    */
176 178
   @Override
177
   public int orderByNulls(StringBuilder sb, String expression, String field, boolean asc, boolean forceAsc)
179
   public int orderByNulls(StringBuilder sb,
180
                           String expression,
181
                           String field,
182
                           boolean asc,
183
                           boolean forceAsc,
184
                           boolean isChar)
178 185
   {
179
      sb.append(field != null ? field : expression).append("__null");
180
      if (!asc)
181
      {
182
         sb.append(" desc");
183
      }
184
      else if (forceAsc)
185
      {
186
         sb.append(" asc");
187
      }
188
      sb.append(",");
186
      if (isChar)
187
      {
188
         sb.append(field != null ? field : expression).append("__null");
189
         if (!asc)
190
         {
191
            sb.append(" desc");
192
         }
193
         else if (forceAsc)
194
         {
195
            sb.append(" asc");
196
         }
197
         sb.append(",");
198
      }
189 199
      
190
      return 1 + super.orderByNulls(sb, expression, null, asc, forceAsc);
200
      return 1 + super.orderByNulls(sb, expression, null, asc, forceAsc, isChar);
191 201
   }
192 202
   
193 203
   /**
new/src/com/goldencode/p2j/persist/dialect/P2JH2Dialect.java 2023-11-14 12:04:12 +0000
1466 1466
    *          The sort direction.
1467 1467
    * @param   forceAsc
1468 1468
    *          If {@code true}, force the insertion of the default {@code asc} direction.
1469
    * @param   isChar
1470
    *          {@code true} if the field is of type character, {@code false} otherwise.
1469 1471
    *
1470 1472
    * @return  1, representing the number of expressions which were added to the string builder.
1471 1473
    */
1472 1474
   @Override
1473
   public int orderByNulls(StringBuilder sb, String expression, String field, boolean asc, boolean forceAsc)
1475
   public int orderByNulls(StringBuilder sb,
1476
                           String expression,
1477
                           String field,
1478
                           boolean asc,
1479
                           boolean forceAsc,
1480
                           boolean isChar)
1474 1481
   {
1475
      super.orderByNulls(sb, expression, null, asc, forceAsc);
1482
      super.orderByNulls(sb, expression, null, asc, forceAsc, isChar);
1476 1483
      sb.append(asc ? " nulls last" : " nulls first");
1477 1484
      return 1;
1478 1485
   }