Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F13351765
index.go
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
966 B
Subscribers
None
index.go
View Options
package
db
import
(
"fmt"
"strings"
)
type
CreateIndexSqlBuilder
struct
{
Dialect
DialectType
Name
string
Table
string
Unique
bool
Columns
[]
string
}
type
DropIndexSqlBuilder
struct
{
Dialect
DialectType
Name
string
Table
string
}
func
(
b
*
CreateIndexSqlBuilder
)
ToSQL
()
(
string
,
error
)
{
var
str
strings
.
Builder
str
.
WriteString
(
"CREATE "
)
if
b
.
Unique
{
str
.
WriteString
(
"UNIQUE "
)
}
str
.
WriteString
(
"INDEX "
)
str
.
WriteString
(
b
.
Name
)
str
.
WriteString
(
" on "
)
str
.
WriteString
(
b
.
Table
)
if
len
(
b
.
Columns
)
==
0
{
return
""
,
fmt
.
Errorf
(
"columns provided for this index: %s"
,
b
.
Name
)
}
str
.
WriteString
(
" ("
)
columnCount
:=
len
(
b
.
Columns
)
for
i
,
thing
:=
range
b
.
Columns
{
str
.
WriteString
(
thing
)
if
i
<
columnCount
-
1
{
str
.
WriteString
(
", "
)
}
}
str
.
WriteString
(
")"
)
return
str
.
String
(),
nil
}
func
(
b
*
DropIndexSqlBuilder
)
ToSQL
()
(
string
,
error
)
{
return
fmt
.
Sprintf
(
"DROP INDEX %s on %s"
,
b
.
Name
,
b
.
Table
),
nil
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 17, 4:48 AM (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3576500
Attached To
rWF WriteFreely
Event Timeline
Log In to Comment