jmoiron / sqlx

general purpose extensions to golang's database/sql
http://jmoiron.github.io/sqlx/
MIT License
15.95k stars 1.07k forks source link

missing destination name trx_id #576

Open ShmSeeker opened 4 years ago

ShmSeeker commented 4 years ago

when i query INNODB_TRX's info ,it report tis error. type TransactionInfo struct { trxId int64 db:"trx_id" trxState string db:"trx_state" trxStarted string db:"trx_started" trxRequestedLockId string trxWaitStarted string trxWeight string trxMysqlThreadId string trxQuery string trxOperationState string trxTablesInUse string trxTablesLocked string trxLockStructs string trxLockMemoryBytes string trxRowsLocked string trxRowsModified string trxConcurrencyTickets string TrxIsolationLevel string trxUniqueChecks string trxForeignKeyChecks string trxLastForeignKeyError string trxAdaptiveHashLatched string trxAdaptiveHashTimeout string trxIsReadOnly string trxAutocommitNonLocking string }

err := db.Select(&result, "SELECT * FROM INFORMATION_SCHEMA.INNODB_TRX")

missing destination name trx_id in *[]main.TransactionInfo

ghost commented 4 years ago

That is because trx_id is a private field. The first letter should be uppercase. If you don't want your field to be returned to the user (in your API) - set json:"-" tag.