| Age | Commit message (Collapse) | Author |
|
|
|
The Meta method returns new instance of [Meta] based on the current
client driver and kind arugment.
While at it, update comments on most methods to use adjectives.
|
|
Changes the BindWhere parameters from two to four.
The first parameter is the OR/AND logic.
The second parameter is the column name.
The third parameter is the operator like "=", "!=".
The fourth parameter is the value.
|
|
With help of spdxconv tool [1], we able to bulk update all files license
and copyright format to comply with SPDX formats.
[1] https://kilabit.info/project/spdxconv/
|
|
|
|
Accepting the [http.FileSystem] means that the parameter can receive an
instance of [embed.FS], but in most cases, it will fail.
Case example, when we embed SQL files for migration under
"db/migration" using the "go:embed" directive,
//go:embed db/migration/*.sql
var DBMigrationFS embed.FS
and then call the [Migrate] function, it will not found any ".sql" files
inside the "/" directory because the files is stored under
"db/migration/" prefix (also there is no "/" when using embed.FS).
|
|
The Row type has been replaced with Meta type with more flexibility
and features for generating type-safe SQL DML.
|
|
HTTP request now implicitly create request with context.
Any false positive related to not closing HTTP response body has been
annotated with "nolint:bodyclose".
In the example code, use consistent "// Output:" comment format, by
prefixing with single space.
Any comment on code now also prefixing with single space.
An error returned without variables now use [errors.New] instead of
[fmt.Errorf].
Any error returned using [fmt.Errorf] now wrapped using "%w" instead of
"%s".
Also, replace error checking using [errors.Is] or [errors.As], instead
of using equal/not-equal operator.
Any statement like "x = x OP y" now replaced with "x OP= y".
Also, swap statement is simplified using "x, y = y, x".
Any switch statement with single case now replaced with if-condition.
Any call to defer on function or program that call [os.Exit], now
replaced by calling the deferred function directly.
Any if-else condition now replaced with switch statement, if possible.
|
|
Instead of annotating the lines that caught by linters, fix it to comply
with the recommendations.
This causes several breaking changes, especially related to naming,
* api/slack: [Message.IconUrl] become [Message.IconURL]
* lib/dns: DefaultSoaMinumumTtl become DefaultSoaMinimumTTL
* lib/email: [Message.SetBodyHtml] become [Message.SetBodyHTML]
* lib/http: [Client.GenerateHttpRequest] become
[Client.GenerateHTTPRequest]
* lib/http: [ClientOptions.ServerUrl] become [ClientOptions.ServerURL]
* lib/http: [EndpointRequest.HttpWriter] become
[EndpointRequest.HTTPWriter]
* lib/http: [EndpointRequest.HttpRequest] become
[EndpointRequest.HTTPRequest]
* lib/http: [ServerOptions.EnableIndexHtml] become
[ServerOptions.EnableIndexHTML]
* lib/http: [SSEConn.HttpRequest] become [SSEConn.HTTPRequest]
* lib/smtp: [ClientOptions.ServerUrl] become [ClientOptions.ServerURL]
* lib/ssh/sftp: [FileAttrs.SetUid] become [FileAttrs.SetUID]
* lib/ssh/sftp: [FileAttrs.Uid] become [FileAttrs.UID]
|
|
There are several reasons that why we move from github.com.
First, related to the name of package.
We accidentally name the package with "share" a common word in English
that does not reflect the content of repository.
By moving to other repository, we can rename it to better and unique
name, in this "pakakeh.go".
Pakakeh is Minang word for tools, and ".go" suffix indicate that the
repository related to Go programming language.
Second, supporting open source.
The new repository is hosted under sourcehut.org, the founder is known
to support open source, and all their services are licensed under AGPL,
unlike GitHub that are closed sources.
Third, regarding GitHub CoPilot.
The GitHub Terms of Service [1], allow any public content that are hosted
there granted them to parse the content.
On one side, GitHub helps and flourish the open source, but on another
side have an issues regarding scraping the copyleft license [2].
[1]: https://docs.github.com/en/site-policy/github-terms/github-terms-of-service#4-license-grant-to-us
[2]: https://githubcopilotinvestigation.com
|
|
|
|
If [Meta.Bind] is called with the same name again, it should replace
the existing named value.
|
|
When binding parameter with BindWhere, the first parameter will be joined
with the holder. For example, BindWhere("colname>=", p) will result in
"colname>=$1".
While at it, set offset based on [Meta.kind].
|
|
This type has never been used and the implementation is not correct.
|
|
This changes add parameter kind to NewMeta, which define the kind of
DML to be mapped by Meta.
The method Add renamed to Bind, and AddWhere renamed to BindWhere.
New methods added to Meta,
- Sub return the child of Meta for building subquery,
- UpdateValues return the merged of ListValue and ListWhereValue
for DML UPDATE
- WhereFields return string that merge the ListWhereCond and ListHolder
separated by "="
|
|
The WhereHolder method generate string of holder, for example "$1,$2,...",
based on number of item added with [Meta.AddWhere].
Similar to method Holders but for where condition.
|
|
Meta contains the DML meta data, including driver name, list of column
names, list of column holders, and list of values.
The Meta type replace the Row type.
|
|
|
|
The DmlKind define the kind for Data Manipulation Language.
|
|
|
|
Since Go 1.16, the ioutil package has been deprecated.
This changes replace any usage that use functions from ioutil package
with their replacement from package os or package io.
|
|
In the method Migrate() we add parameter "tableMigration" which define
the name of table where the state of migration will be saved.
If its empty default to "_migration".
|
|
On table that contains foreign key, truncate without cascade may cause
the method fail.
Also, since TruncateTable is, and should be only, used on testing, any
identity columns, for example serial, should be reset back to its initial
value. On PostgreSQL this means the truncate table is with
"RESTART IDENTITY".
|
|
There is probably a regression in Go that cause ioutil.ReadAll return
io.EOF, while it should not, because the documentation said that
A successful call returns err == nil, not err == EOF.
But in this, using http.FileSystem, the ioutil.ReadAll now return EOF
and we need to check it to make the migration can run without an error.
|
|
Previously, if the last migrated file name not found on the migration
directory, we start executing migration start from the first file.
This changes this behaviour to not run any migration at all.
Since we cannot return it as an error, we only log it. In the future
we may return it.
|
|
This will allow deleting the record by filename instead of requiring
all columns.
|
|
This is to give an overview what the values hold after the call.
|
|
Previously, we use the string as parameter to set the returned place
holders.
This commit changes the parameter to the driver name so if the value
is "postgres" the place holders will be returned as counter, for example
"$1", "$2", and so on.
|
|
This is to make sure that any test that use the package always
predictable.
While at it, add paramter to change placeholder on ExtractSQLFields.
|
|
If we pass nil pointer of type to fs, the if condition will not true
and this cause panic because fs is not nil.
|
|
If case the file-system argument is not provided, the function will
assume that the migration script is stored in the MigrationDir which
defined in ClientOptions.
|
|
While at it, rename the function from "New" to "NewClient" for clarity.
|
|
|
|
|
|
|
|
The Migrate method migrate the database using list of SQL files inside
a directory.
Each SQL file in directory will be executed in alphabetical order based on
the last state.
The state of migration will be saved in table "_migration" with the SQL
file name that has been executed and the timestamp.
|
|
|