Giter Site home page Giter Site logo

protoc-gen-map's People

Contributors

jackskj avatar jfkw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

protoc-gen-map's Issues

protoc-gen-go/generator is deprecated

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

Conflicting Enums

If multiple proto files in the same package contain enums, there will be more than one EnumValueMaps declarations in the same package

Use QueryContext and ExecContext

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:

  • templates/unary_response.go
	{{ 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 {
  • templates/streaing_response.go
	rows, err := m.DB.QueryContext(stream.Context(), rawSql)
	if err != nil {

Today all database support Context, if not have a fallback.

Thanks.

varchar not converted to string

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?

SQL Injection

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!

MySQL Support

Hello, protoc-gen-map looks great! Any plans to add MySQL support?

Use Prepared Statements

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.

funny work

It is really good idea, i will watch it

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.