Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate database and collection names for SQLite handler #2868

Merged
merged 89 commits into from
Jul 26, 2023
Merged
Changes from 1 commit
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
6e3df55
wip
noisersup Jun 20, 2023
8a2af00
wip
noisersup Jun 21, 2023
ae491af
wip
noisersup Jun 21, 2023
3f84105
basic
noisersup Jun 22, 2023
a5ca6cb
remove CollectionToTable from struct
noisersup Jun 22, 2023
88182fb
Replace with collectionGet
noisersup Jun 22, 2023
2009ea8
it works???
noisersup Jun 22, 2023
07738c7
test case
noisersup Jun 23, 2023
004aa8e
wip
noisersup Jun 23, 2023
1178e65
prefix validation
noisersup Jun 23, 2023
019ceb7
Merge branch 'main' into validate-db-coll-2749
noisersup Jun 23, 2023
8c3714d
tweak
noisersup Jun 23, 2023
1012a42
wip
noisersup Jun 23, 2023
7230c38
fix dot for postgres
noisersup Jun 26, 2023
176cb05
fix dot for sqlite
noisersup Jun 26, 2023
f184458
Merge remote-tracking branch 'upstream/main' into validate-db-coll-2749
noisersup Jun 26, 2023
2fbbd64
Update sqlite comment
noisersup Jun 26, 2023
dac0fa9
wip
noisersup Jun 26, 2023
f97a473
add sqlite validation
noisersup Jun 26, 2023
c179a50
add comment + lint
noisersup Jun 27, 2023
4bfe05b
fmt
noisersup Jun 27, 2023
825b11b
Merge branch 'main' into validate-db-coll-2749
noisersup Jun 27, 2023
4d98281
wip
noisersup Jun 27, 2023
0332333
wip
noisersup Jun 27, 2023
257e866
make all table names lowercase
noisersup Jun 27, 2023
7505d9a
proper error handling
noisersup Jun 27, 2023
f05bf62
lot of changes
noisersup Jun 27, 2023
15d7c77
Merge remote-tracking branch 'upstream/main' into validate-db-coll-2749
noisersup Jun 27, 2023
1ef2680
wip
noisersup Jun 27, 2023
a16bb20
fix
noisersup Jun 27, 2023
12a80e4
wip
noisersup Jun 27, 2023
2db636d
wip
noisersup Jun 27, 2023
ef77cfe
wip
noisersup Jun 27, 2023
9463201
Merge branch 'main' into validate-db-coll-2749
Jun 28, 2023
494dcd7
pair programming
noisersup Jun 28, 2023
53518ae
improve prefix check
noisersup Jun 28, 2023
3b95fe1
wip
noisersup Jun 28, 2023
af07a45
Merge branch 'fix-after-bump' into validate-db-coll-2749
noisersup Jun 28, 2023
b3d66ab
Remove test
noisersup Jun 28, 2023
10dcbaa
Merge branch 'fix-after-bump' into validate-db-coll-2749
noisersup Jun 28, 2023
1c2f423
apply review comments
noisersup Jun 28, 2023
8f5667c
Merge branch 'main' into validate-db-coll-2749
Jun 28, 2023
c266454
Merge branch 'main' into validate-db-coll-2749
AlekSi Jun 29, 2023
c5fc06d
Update issue comment
AlekSi Jun 29, 2023
50694df
Simplify
AlekSi Jun 29, 2023
a8bb524
rename CollectionGet
noisersup Jun 29, 2023
c81bc84
remove comment
noisersup Jun 29, 2023
877d7d6
Merge branch 'main' into validate-db-coll-2749
Jun 30, 2023
cb80f54
wip
noisersup Jun 30, 2023
a3b9649
wip
noisersup Jun 30, 2023
7c075bc
wip
noisersup Jun 30, 2023
43c36ae
wip
noisersup Jun 30, 2023
22ff58d
lint
noisersup Jun 30, 2023
0d617a5
Merge branch 'main' into validate-db-coll-2749
Jun 30, 2023
6780ab3
remove unused errorcode
noisersup Jun 30, 2023
50397c1
remove empty collection error from update
noisersup Jun 30, 2023
af88550
Merge remote-tracking branch 'upstream/main' into validate-db-coll-2749
noisersup Jun 30, 2023
1b1a1f4
cleanup
noisersup Jun 30, 2023
122b3fe
Merge branch 'main' into validate-db-coll-2749
AlekSi Jul 2, 2023
6922636
Merge branch 'main' into pr/noisersup/2868-1
AlekSi Jul 14, 2023
88c3c77
Merge branch 'main' into validate-db-coll-2749
AlekSi Jul 18, 2023
5e519bd
Tweak comment
AlekSi Jul 19, 2023
81eb51d
Merge branch 'main' into pr/noisersup/2868
AlekSi Jul 19, 2023
75706fd
Update comments
AlekSi Jul 19, 2023
8346e0c
Merge branch 'main' into pr/noisersup/2868
AlekSi Jul 19, 2023
e4e77bf
Add linter configuration
AlekSi Jul 19, 2023
eaf50a9
Improve tests
AlekSi Jul 19, 2023
d95cca4
Tweaks
AlekSi Jul 19, 2023
5fef6b7
Do not import `commonerrors` in tests
AlekSi Jul 19, 2023
0b96a31
Merge branch 'commonerrors' into pr/noisersup/2868
AlekSi Jul 19, 2023
c875dd1
More work
AlekSi Jul 19, 2023
14e2bff
Add comment
AlekSi Jul 19, 2023
67f909b
Create unique index
AlekSi Jul 19, 2023
a500b14
Merge branch 'main' into validate-db-coll-2749
AlekSi Jul 20, 2023
b6d2961
Make SQLite URL configurable
AlekSi Jul 20, 2023
6a35453
Add validation
AlekSi Jul 20, 2023
a18b8f2
Merge branch 'main' into pr/noisersup/2868
AlekSi Jul 20, 2023
e070733
Merge branch 'main' into validate-db-coll-2749
AlekSi Jul 26, 2023
c5cc1d5
Update comments
AlekSi Jul 26, 2023
be93b2d
Tweak validation
AlekSi Jul 26, 2023
fe79866
Fix number
AlekSi Jul 26, 2023
1344019
Merge branch 'main' into validate-db-coll-2749
AlekSi Jul 26, 2023
1c72efc
Update comment
AlekSi Jul 26, 2023
cc083fa
Update comments
AlekSi Jul 26, 2023
296973f
Tiny tweak
AlekSi Jul 26, 2023
20f8200
Fix tests
AlekSi Jul 26, 2023
0cc1df7
Merge branch 'main' into validate-db-coll-2749
AlekSi Jul 26, 2023
c39f316
Lint
AlekSi Jul 26, 2023
e266e35
Add explicit panic
AlekSi Jul 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tweak
  • Loading branch information
noisersup committed Jun 23, 2023
commit 8c3714d368fe6972374b696156e42b38d8d21a7b
18 changes: 6 additions & 12 deletions internal/backends/sqlite/metadata/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,22 +201,16 @@ func (r *Registry) CollectionGet(ctx context.Context, dbName string, collectionN
}
defer rows.Close()

var res []string

for rows.Next() {
var name string
if err = rows.Scan(&name); err != nil {
return "", lazyerrors.Error(err)
}

res = append(res, name)
if !rows.Next() {
return "", lazyerrors.New("no collection found")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's not a lazy error but some other error? Maybe the easiest way is to run some test that already queries/modifies a non-existent collection to see how this should reflect it.

chilagrow marked this conversation as resolved.
Show resolved Hide resolved
}

if len(res) != 1 {
return "", fmt.Errorf("res:%d", len(res))
var name string
if err = rows.Scan(&name); err != nil {
return "", lazyerrors.Error(err)
}

return res[0], err
return name, nil
}

// CollectionDrop drops a collection in the database.
Expand Down