jackskj / protoc-gen-map Goto Github PK
View Code? Open in Web Editor NEWSQL Data mapper framework for grpc/protobuf
License: Apache License 2.0
SQL Data mapper framework for grpc/protobuf
License: Apache License 2.0
When executing the binary "go/bin/protoc-gen-map", there is a warning about "protoc-gen-go/generator" to be deprecated:
WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated.
A future release of golang/protobuf will delete this package,
which has long been excluded from the compatibility promise.
Is there an updated or replacement package for this? Is there a plan to fix this in the near future?
Thanks,
H
If multiple proto files in the same package contain enums, there will be more than one EnumValueMaps declarations in the same package
First, an Excellent project.
To prevent queries running when the client finishes the connection we need to cancel the query.
WDYT using QueryContext?
I do the changes but I'm unable to run the tests. (Bazel errors)
Changes:
{{ if eq .QueryType "Exec" }}
_, err := m.DB.ExecContext(ctx, rawSql)
if err != nil {
// ...
{{ else if eq .QueryType "Query" }}
rows, err := m.DB.QueryContext(ctx, rawSql)
if err != nil {
rows, err := m.DB.QueryContext(stream.Context(), rawSql)
if err != nil {
Today all database support Context, if not have a fallback.
Thanks.
Following the code under "examples" in this repository, I've brought up a MySQL DB and a simple server based on "server.go". I've created the "blog" table as per the "testdata/initdb/sql/init_db.sql" example and added some values. Finally, I've created a test client. Connections and mapping work for integer values and I get a correct BlogResponse. However, the varchar "title" field is blank.
After some debugging, I found that it was not correctly converted. The varchar was read as a []uint8 from the DB. I modified the function "MapResponse" in "mapper.go" to include a conversion to a string. Something like this:
func B2S(bs []uint8) string {
b := make([]byte, len(bs))
for i, v := range bs {
b[i] = byte(v)
}
return string(b)
}
func (m *Mapper) MapResponse(respMap *ResponseMapping) error {
....
arrayUint8, ok := sqlMapVals.ProtoValues[i].([]uint8)
if ok == true {
str := B2S(arrayUint8)
setProto(respField, str)
} else {
setProto(respField, sqlMapVals.ProtoValues[i])
}
With that fix, the full BlogResponse object is returned correctly.
Is this a known problem? I have configured the DB (MySql / MariaDB) wrong? Or maybe it's a driver or configuration problem?
Hi there,
I really like the look of this project, and it could be very helpful for me. However does the approach you are taking protect against any sort of SQL injection?
Generally I would expect the SQL statement to be defined as such, notice the ?
instead of {{ .Id }}
{{ define "SelectBlog" }}
select
id,
title,
author_id
from blog
where id = ? limit 1
{{ end }}
Then the Id
argument to be passed into the query:
rows, err := m.DB.Query(rawSql, r.Id)
defer rows.Close()
...
It looks as though this is not happening and raw input is just being passed straight into the query. Have you thought about a way to prevent an attack?
Or am I just missing something?
Thanks for the work!
Hello, protoc-gen-map looks great! Any plans to add MySQL support?
To gain performance for some queries, we can use prepared statements on supported databases.
Some idea is to save the prepared query (*sql.Stmt) on a map (with mutex :) ).
The key of the map can be a hash of the query or something faster to calculate this key. (For example the RPC method).
TODO: Add an example.
It is really good idea, i will watch it
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.