Skip to content

Commit c0a7ab0

Browse files
lxfeng1997AsterZephyrluky116Code-Fightpanlei-coder
authored
bugfix: error image when use null value as image query condition in insert on duplicate #704 (#725) (#884)
* bugfix: error image when use null value as image query condition in insert on duplicate #704 (#725) * bugfix #704 * bugfix #704 * bugfix704-2 * bugfix-test-2 * bugfix-test-2 * pr725 bugfix --------- Co-authored-by: JayLiu <[email protected]> Co-authored-by: FengZhang <[email protected]> * fix: Solve the conflict problem of introducing multiple versions of knadh (#772) * fix: Solve the conflict problem of introducing multiple versions of knadh * fix: fix ci fail --------- Co-authored-by: JayLiu <[email protected]> Co-authored-by: FengZhang <[email protected]> * the ability to automatically run unit tests after creating a pull request. (#764) * feat: add unit test workflow * feat:the ability to automatically run unit tests after creating a pull request. * feat:the ability to automatically run unit tests after creating a pull request. * feat:the ability to automatically run unit tests after creating a pull request. * feat:the ability to automatically run unit tests after creating a pull request. * feat:the ability to automatically run unit tests after creating a pull request. * feat:the ability to automatically run unit tests after creating a pull request. * Optimize/at build lock key performance (#837) * Refer to buildlockkey2 optimization #829 * Time complexity O(NM)-> O(NK) about buildlockkey and buildlockkey2 Increased readability #829 * update import sort #829 * update Encapsulation into util packages #829 * Support Update join (#761) * duplicate image row for update join * update join condition placeholder param error * update join bugfix * Open test annotations * recover update executor * recover update test * recover update test * modified version param --------- Co-authored-by: JayLiu <[email protected]> Co-authored-by: FengZhang <[email protected]> --------- Co-authored-by: jimin <[email protected]> Co-authored-by: JayLiu <[email protected]> Co-authored-by: FengZhang <[email protected]> Co-authored-by: Wiggins <[email protected]> Co-authored-by: lxfeng1997 <[email protected]> * merge master * Improve the test cases * upload upload-artifact to v4 * chore(ci): update Go version to 1.20.14 --------- Co-authored-by: Aster Zephyr <[email protected]> Co-authored-by: JayLiu <[email protected]> Co-authored-by: FengZhang <[email protected]> Co-authored-by: panlei-coder <[email protected]> Co-authored-by: jimin <[email protected]> Co-authored-by: Wiggins <[email protected]>
1 parent be1ad86 commit c0a7ab0

File tree

5 files changed

+349
-91
lines changed

5 files changed

+349
-91
lines changed

.github/workflows/unit-test.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
name: "Unit Test"
19+
20+
on:
21+
push:
22+
branches: [ master ]
23+
pull_request:
24+
branches: [ "*" ]
25+
types: [opened, synchronize, reopened]
26+
27+
permissions:
28+
contents: read
29+
30+
jobs:
31+
unit-test:
32+
name: Unit Test
33+
runs-on: ubuntu-latest
34+
timeout-minutes: 10
35+
strategy:
36+
matrix:
37+
golang:
38+
- 1.20.14
39+
40+
steps:
41+
- name: "Set up Go"
42+
uses: actions/setup-go@v3
43+
with:
44+
go-version: ${{ matrix.golang }}
45+
46+
- name: "Checkout code"
47+
uses: actions/checkout@v3
48+
with:
49+
submodules: true
50+
51+
- name: "Cache dependencies"
52+
uses: actions/cache@v3
53+
with:
54+
path: ~/go/pkg/mod
55+
key: "${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}"
56+
restore-keys: |
57+
"${{ runner.os }}-go-"
58+
59+
- name: Shutdown default mysql
60+
run: sudo service mysql stop
61+
62+
63+
- name: "Run Unit Tests"
64+
run: |
65+
echo "=== Starting Unit Tests ==="
66+
go test -v ./... -race -coverprofile=coverage.txt -covermode=atomic -timeout 10m
67+
if [ $? -ne 0 ]; then
68+
echo "❌ Unit tests failed"
69+
exit 1
70+
fi
71+
echo "✅ Unit tests completed successfully"
72+
73+
- name: "Archive test results"
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: test-results
77+
path: coverage.txt
78+
retention-days: 7
79+
overwrite: true

pkg/datasource/sql/types/image.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package types
1919

2020
import (
21+
"database/sql/driver"
2122
"encoding/base64"
2223
"encoding/json"
2324
"reflect"
@@ -117,14 +118,16 @@ type RecordImage struct {
117118
// Rows data row
118119
Rows []RowImage `json:"rows"`
119120
// TableMeta table information schema
120-
TableMeta *TableMeta `json:"-"`
121+
TableMeta *TableMeta `json:"-"`
122+
PrimaryKeyMap map[string][]driver.Value `json:"primaryKeyMap,omitempty"`
121123
}
122124

123125
func NewEmptyRecordImage(tableMeta *TableMeta, sqlType SQLType) *RecordImage {
124126
return &RecordImage{
125-
TableName: tableMeta.TableName,
126-
TableMeta: tableMeta,
127-
SQLType: sqlType,
127+
TableName: tableMeta.TableName,
128+
TableMeta: tableMeta,
129+
SQLType: sqlType,
130+
PrimaryKeyMap: make(map[string][]driver.Value),
128131
}
129132
}
130133

pkg/datasource/sql/undo/builder/basic_undo_log_builder_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,24 @@ func TestBuildLockKey(t *testing.T) {
117117
},
118118
"TEST2_NAME:1_one_11,2_two_22,3_three_33",
119119
},
120+
{
121+
"Three Primary Keys",
122+
types.TableMeta{
123+
TableName: "test2_name",
124+
Indexs: map[string]types.IndexMeta{
125+
"PRIMARY_KEY": {IType: types.IndexTypePrimaryKey, Columns: columnsThreePk},
126+
},
127+
},
128+
types.RecordImage{
129+
TableName: "test2_name",
130+
Rows: []types.RowImage{
131+
{[]types.ColumnImage{getColumnImage("id", 1), getColumnImage("userId", "one"), getColumnImage("age", "11")}},
132+
{[]types.ColumnImage{getColumnImage("id", 2), getColumnImage("userId", "two"), getColumnImage("age", "22")}},
133+
{[]types.ColumnImage{getColumnImage("id", 3), getColumnImage("userId", "three"), getColumnImage("age", "33")}},
134+
},
135+
},
136+
"TEST2_NAME:1_one_11,2_two_22,3_three_33",
137+
},
120138
{
121139
name: "Single Primary Key",
122140
metaData: types.TableMeta{

0 commit comments

Comments
 (0)