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

feat : add max size parameter for string and truncate output #6

Open
youen opened this issue Oct 9, 2021 · 4 comments
Open

feat : add max size parameter for string and truncate output #6

youen opened this issue Oct 9, 2021 · 4 comments

Comments

@youen
Copy link
Collaborator

youen commented Oct 9, 2021

Problem

Column definition in database have a max size definition. Trying to insert a bigger value with lino push failed.

Proposal

Define a template with max size parameter that truncate string longer than max size definition.

$ jl -t '{"name": "string(4)"}' <<EOF
{"name": "Martin"}
EOF
{"name":"Mart"}
@adrienaury
Copy link
Member

The proposed syntax will conflict with the way to define the raw type (for example jl -t '{"value":"binary(int64)"}' < file.jsonl)

So we need another notation.

@youen
Copy link
Collaborator Author

youen commented Oct 9, 2021

What is a raw type for a string ?

@adrienaury
Copy link
Member

For example :

jl -t '{"value":"string([]byte)"}' < file.jsonl

The string value read from JSON will be transformed and the database driver will receive a []byte instead of a string.

@adrienaury
Copy link
Member

Here is a syntax with possibility to extend to other parameters

jl -t '{"name": "string(size=4)"}'
jl -t '{"name": "string([]byte,size=4)"}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants