go-tarantool icon indicating copy to clipboard operation
go-tarantool copied to clipboard

Datetime docs?

Open zachgrayio opened this issue 2 years ago • 3 comments
trafficstars

given schema

box.schema.space.create('some_space', {
    format = {
        {name = 'somedate', type = 'datetime'},
        ... 
    }
})

trying to write some data with the go driver gets me:

Tuple field 13 (somedate) type does not match one required by operation: expected datetime, got string

changing the schema to type = 'string' and it seems to just work fine, so I assume either the datetime package isn't functioning as expected, and again there's no docs or full examples. is this expected? am I doing something wrong? can we get some docs created someday?

zachgrayio avatar Apr 02 '23 21:04 zachgrayio

Hello, could you please provide a reproducer with the connector code?

There is an example:

https://pkg.go.dev/github.com/tarantool/[email protected]/datetime#example-package

https://github.com/tarantool/go-tarantool/blob/64e41c5798b0de75ab97d527afb67abdc40760d1/datetime/example_test.go#L21-L81

oleg-jukovec avatar Apr 02 '23 21:04 oleg-jukovec

After spending some more time on this probably the issue was somewhere else in the stack, though with a clearer example somewhere I could have ruled it out sooner before coming here.

In particular, you aren't showing an end to end example of saving this into a space (what does the space def look like in the example tests you shared?)

Also lacking is a complete example of a real entity/struct defined actually using the datetime type as a member prop etc so you really need to be motivated to find the answer, not great for newcomers to tarantool which I would assume many users of the Golang drivers will be

zachgrayio avatar Apr 03 '23 00:04 zachgrayio

The space has a just datetime field:

https://github.com/tarantool/go-tarantool/blob/ab1fb930328e8a680ef2537b25be77f8b94bf5a0/datetime/config.lua#L17

Let's summarize. We need to improve our datetime examples:

  1. Add a comment with space.create().
  2. Add an example with a tuple as a custom structure type.

oleg-jukovec avatar Apr 03 '23 07:04 oleg-jukovec