1
0
Fork 0

More code in db.Request()

master
Philip O'Toole 1 year ago
parent 6fcf85ef40
commit de70664bf1

@ -662,9 +662,20 @@ func (db *DB) queryWithConn(req *command.Request, xTime bool, conn *sql.Conn) ([
return allRows, err return allRows, err
} }
func (db *DB) queryStmtWithConn(stmt *command.Statement, conn *sql.Conn) ([]*command.QueryRows, error) {
return nil, nil
}
func (db *DB) Request(req *command.Request, xTime bool) ([]*command.ExecuteQueryResponse, error) { func (db *DB) Request(req *command.Request, xTime bool) ([]*command.ExecuteQueryResponse, error) {
// Handle Txs. XXX // Handle Txs. XXX
// Get the connection
conn, err := db.rwDB.Conn(context.Background())
if err != nil {
return nil, err
}
defer conn.Close()
eqResponse := make([]*command.ExecuteQueryResponse, len(req.Statements)) eqResponse := make([]*command.ExecuteQueryResponse, len(req.Statements))
for i, stmt := range req.Statements { for i, stmt := range req.Statements {
ss := stmt.Sql ss := stmt.Sql
@ -674,11 +685,20 @@ func (db *DB) Request(req *command.Request, xTime bool) ([]*command.ExecuteQuery
ro, err := db.StmtReadOnly(ss) ro, err := db.StmtReadOnly(ss)
if err != nil { if err != nil {
return nil, err // assume this is an actual error, not, say, syntax XXX CHECK IT eqResponse[i] = &command.ExecuteQueryResponse{
Result: &command.ExecuteQueryResponse_Q{
Q: &command.QueryRows{
Error: err.Error(),
},
},
}
continue
} }
if ro { if ro {
rows, err := db.QueryStringStmt(ss) /// HANG ON!!! THIS WON"T WORK -- named parameters etc!!! rows, err := db.QueryStringStmt(ss) /// HANG ON!!! THIS WON"T WORK -- named parameters etc!!!
rows, err = db.queryWithConn(nil, false, conn)
if err != nil { if err != nil {
rows = []*command.QueryRows{ rows = []*command.QueryRows{
{ {

Loading…
Cancel
Save