From a840f497b8122ee70cc437fca2d3e83a34a0f21c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Fri, 25 Aug 2023 04:28:56 +0200 Subject: [PATCH] Fix DataSource.Find() on MySQL. DataView now correctly unselect all lines when we are in creation mode and the view is not editable. [GB.DB.FORM] * BUG: DataTable: Write the SQL request of the Find() method is a way that is compatible with MySQL. * BUG: DataView: Correctly unselect all lines when we are in creation mode and the view is not editable. --- comp/src/gb.db.form/.src/DataTable.class | 4 ++-- comp/src/gb.db.form/.src/DataView.class | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/comp/src/gb.db.form/.src/DataTable.class b/comp/src/gb.db.form/.src/DataTable.class index dfd8fdd33..4aaa55893 100644 --- a/comp/src/gb.db.form/.src/DataTable.class +++ b/comp/src/gb.db.form/.src/DataTable.class @@ -171,7 +171,7 @@ Public Sub Find(sWhere As String, Optional iFrom As Integer) As Integer Dim rFind As Result sSelect = "ROW_NUMBER() OVER (" & $DB.SQL.OrderBy(GetSortKeys())() & ") AS __index" - sReq = $DB.SQL.Select([sSelect, "*"]).From($sTable).Where($sFilter)() + sReq = $DB.SQL.Select(["*", sSelect]).From($sTable).Where($sFilter)() sReq = "SELECT * FROM (" & sReq & ") AS __pg_sucks WHERE " & sWhere If iFrom > 0 Then sReq &= " AND __index >= " & CStr(iFrom + 1) @@ -180,7 +180,7 @@ Public Sub Find(sWhere As String, Optional iFrom As Integer) As Integer If rFind.Count = 0 Then Return -1 Else - Return rFind[0] - 1 + Return rFind["__index"] - 1 Endif End diff --git a/comp/src/gb.db.form/.src/DataView.class b/comp/src/gb.db.form/.src/DataView.class index 50690bb84..e989eb536 100644 --- a/comp/src/gb.db.form/.src/DataView.class +++ b/comp/src/gb.db.form/.src/DataView.class @@ -89,6 +89,7 @@ Public Sub _new() $bAllColumns = True Update Create() + UpdateMode $bHighlight = True UpdateHighlightColor @@ -941,7 +942,7 @@ Private Sub UpdateMode() Object.Lock($hCtrl) - If $bCreate And If HasNewRecord() Then + If $bCreate And If Not HasNewRecord() Then $hCtrl.Mode = Select.None Else $hCtrl.Mode = $iMode