MCPcopy Index your code
hub / github.com/dropbox/godropbox / String

Method String

database/sqlbuilder/statement.go:910–943  ·  view source on GitHub ↗
(database string)

Source from the content-addressed store, hash-verified

908}
909
910func (s *lockStatementImpl) String(database string) (sql string, err error) {
911 if !validIdentifierName(database) {
912 return "", errors.New("Invalid database name specified")
913 }
914
915 if len(s.locks) == 0 {
916 return "", errors.New("No locks added")
917 }
918
919 buf := new(bytes.Buffer)
920 _, _ = buf.WriteString("LOCK TABLES ")
921
922 for idx, lock := range s.locks {
923 if lock.t == nil {
924 return "", errors.Newf("nil table. Generated sql: %s", buf.String())
925 }
926
927 if err = lock.t.SerializeSql(database, buf); err != nil {
928 return
929 }
930
931 if lock.w {
932 _, _ = buf.WriteString(" WRITE")
933 } else {
934 _, _ = buf.WriteString(" READ")
935 }
936
937 if idx != len(s.locks)-1 {
938 _, _ = buf.WriteString(", ")
939 }
940 }
941
942 return buf.String(), nil
943}
944
945// NewUnlockStatement returns SQL statement that can be used to release table locks
946// grabbed by the current session.

Callers

nothing calls this directly

Calls 5

NewFunction · 0.92
NewfFunction · 0.92
validIdentifierNameFunction · 0.85
StringMethod · 0.65
SerializeSqlMethod · 0.65

Tested by

no test coverage detected