Description

When I use SQLite as the engine and use CreateInBatch to dynamically insert table data, I specify values as []map[string]interface{}. If the key of the map contains a., then the SQL statement executed will be concatenated incorrectly

Gorm Version: v1.25.0

package main

import (
    "gorm.io/driver/sqlite"
    "gorm.io/gorm"
)

func main() {
    db, err := gorm.Open(sqlite.Open(":memory:"))
    if err != nil {
        panic(err)
    }
    table := "create table myTable" +
        "(id bigint auto_increment," +
        "docid varchar(256) not null, `src_ip` varchar(512) not null," +
        "`dst_port` bigint not null," +
        "`protocol_data.http.method` varchar(512) not null," +
        "`dst_ip` varchar(512) not null," +
        "`attack_type` varchar(512) not null," +
        "`attack_method` varchar(512) not null," +
        "`attack_time` bigint not null," +
        "constraint myTable primary key (id));"
    err = db.Exec(table).Error
    if err != nil {
        panic(err)
    }

    record := []map[string]interface{}{
        {
            "attack_method":             "xxx",
            "attack_type":               "xxxx",
            "dst_ip":                    "1.1.1.1",
            "dst_port":                  80,
            "protocol_data.http.method": "xxx",
        },
    }
    err = db.Table("myTable").CreateInBatches(record, 1).Error
    if err != nil {
        panic(err)
    }
}

it's output an error:

[0.117ms] [rows:0] INSERT INTO `myTable` (`attack_method`,`attack_type`,`dst_ip`,`dst_port`,`protocol_data`.`http`.`method`) VALUES ("xxx","xxxx","1.1.1.1",80,"xxx")
panic: near ".": syntax error

protocol_data.http.method should be protocol_data.http.method

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking