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

Support create for capped collections #3614

Merged
merged 35 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
09c7c21
wip
rumyantseva Oct 19, 2023
acfc3eb
wip
rumyantseva Oct 19, 2023
36cafbf
wip
rumyantseva Oct 19, 2023
6b03ca0
wip
rumyantseva Oct 19, 2023
2b288d5
wip
rumyantseva Oct 19, 2023
8f57936
wip
rumyantseva Oct 19, 2023
a1ac944
Merge branch 'main' into issue-3458-create
Oct 19, 2023
53fe697
wip
rumyantseva Oct 19, 2023
0155136
wip
rumyantseva Oct 19, 2023
c825d42
Update internal/backends/sqlite/metadata/registry.go
Oct 20, 2023
8d24039
wip
rumyantseva Oct 20, 2023
b5ccc14
wip
rumyantseva Oct 20, 2023
ce23e40
wip
rumyantseva Oct 20, 2023
578bade
wip
rumyantseva Oct 20, 2023
7b49f0b
Update integration/commands_administration_compat_test.go
Oct 20, 2023
4dfab8c
Merge branch 'main' into issue-3458-create
Oct 20, 2023
b8eb619
wip
rumyantseva Oct 20, 2023
1a9299c
Merge branch 'issue-3458-create' of https://github.com/rumyantseva/Fe…
rumyantseva Oct 20, 2023
bf1d2ab
wip
rumyantseva Oct 20, 2023
799d049
wip
rumyantseva Oct 20, 2023
278972d
wip
rumyantseva Oct 20, 2023
e2eeae6
Merge branch 'main' into issue-3458-create
Oct 20, 2023
04b06b6
wip
rumyantseva Oct 20, 2023
132cf75
Better error
rumyantseva Oct 23, 2023
3eed980
Merge branch 'main' into issue-3458-create
AlekSi Oct 23, 2023
907c4af
wip
rumyantseva Oct 23, 2023
d269272
Merge branch 'issue-3458-create' of https://github.com/rumyantseva/Fe…
rumyantseva Oct 23, 2023
ec8755e
wip
rumyantseva Oct 23, 2023
48dc636
Update internal/backends/postgresql/metadata/metadata.go
Oct 23, 2023
f75012a
Update internal/backends/sqlite/metadata/settings.go
Oct 23, 2023
562d2cd
Update integration/commands_administration_compat_test.go
Oct 23, 2023
aef0773
wip
rumyantseva Oct 24, 2023
afc5470
refactor
chilagrow Oct 24, 2023
eeaa953
cleanup
chilagrow Oct 24, 2023
8d836d7
Merge branch 'main' into issue-3458-create
AlekSi Oct 24, 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
wip
  • Loading branch information
rumyantseva committed Oct 20, 2023
commit 578badec522a1489c8a6df7103e53f09f1d1e07d
2 changes: 1 addition & 1 deletion integration/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func TestCreateCappedCommandInvalidSpec(t *testing.T) {
Name: "TypeMismatch",
Message: "BSON field 'create.capped' is the wrong type 'string', expected types '[bool, long, int, decimal, double']",
},
altMessage: "BSON field 'capped' is the wrong type 'string', expected type 'bool'",
altMessage: "BSON field 'capped' is the wrong type 'string', expected types '[bool, long, int, decimal, double]'",
},
"NegativeSize": {
chilagrow marked this conversation as resolved.
Show resolved Hide resolved
collectionName: "negative_size",
Expand Down
2 changes: 1 addition & 1 deletion integration/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var (

disableFilterPushdownF = flag.Bool("disable-filter-pushdown", false, "disable filter pushdown")
enableSortPushdownF = flag.Bool("enable-sort-pushdown", false, "enable sort pushdown")
enableOplogF = flag.Bool("enable-oplog", false, "enable OpLog")
enableOplogF = flag.Bool("enable-oplog", true, "enable OpLog")
AlekSi marked this conversation as resolved.
Show resolved Hide resolved

useNewHanaF = flag.Bool("use-new-hana", false, "use new SAP HANA backend")
)
Expand Down
22 changes: 13 additions & 9 deletions internal/handlers/sqlite/msg_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,33 +74,37 @@ func (h *Handler) MsgCreate(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg,
Name: collectionName,
}

capped, err := common.GetOptionalParam[bool](document, "capped", false)
if err != nil {
return nil, err
var capped bool
if v, _ := document.Get("capped"); v != nil {
capped, err = commonparams.GetBoolOptionalParam("capped", v)
if err != nil {
return nil, err
}
}

if h.EnableOplog && capped {
// size param is required
var size any

size, err = document.Get("size")
if err != nil {
return nil, err
chilagrow marked this conversation as resolved.
Show resolved Hide resolved
}

if _, ok := size.(types.NullType); ok {
msg := "the 'size' field is required when 'capped' is true"
return nil, commonerrors.NewCommandErrorMsgWithArgument(commonerrors.ErrInvalidOptions, msg, "create")
}

params.CappedSize, err = commonparams.GetValidatedNumberParamWithMinValue(document.Command(), "size", size, 1)
if err != nil {
return nil, err
}

if params.CappedSize%256 != 0 {
params.CappedSize = (params.CappedSize/256 + 1) * 256 // there is a requirement to round up to 256 bytes' multiplier
params.CappedSize = (params.CappedSize/256 + 1) * 256
}

// max param is optional
var max any

if max, err = document.Get("max"); err == nil {
if max, _ := document.Get("max"); max != nil {
params.CappedDocuments, err = commonparams.GetValidatedNumberParamWithMinValue(document.Command(), "max", max, 0)
if err != nil {
return nil, err
Expand Down
Loading