ltsharma / expo-sqlite-query-helper

SQLite query helper library for expo-sqlite
MIT License
9 stars 5 forks source link

About the number of fields inserted #5

Open codthing opened 3 years ago

codthing commented 3 years ago

When I want to insert 3 or more fields, an error is reported.

expect

createTable({
    tableName: 'people',
    tableFields: [
        {
            columnName: 'id',
            dataType: 'INTEGER PRIMARY KEY AUTOINCREMENT',
        },
        {
            columnName: 'name',
            dataType: 'varchar',
        }, {
            columnName: 'age',
            dataType: 'int',
        }, {
            columnName: 'sex',
            dataType: 'varchar',
        },
    ],
});

recurrent

create table

const created = await createTable("changjing", {
    id: "varchar(50)",
    htmlUrl: "varchar(100)",
    typeName: "varchar(100)"
});

want insert 3 col or more

const likeData = {
    id: '1-1',
    htmlUrl: 'https://xx.com',
    typeName: 'music'
}

insert data


const inserted = (insertData: any) => {
    insert('changjing', [insertData])
        .then(({ row, rowAffected, insertID, lastQuery }) => {
            console.log('success', row, rowAffected, insertID, lastQuery);
            setLikeState(true)
            setVisible(true)
            setTiptext('success!')
    })
    .catch((e) => console.log('error:', e));
}

inserted(likeData)

error

image

codthing commented 3 years ago

@ltsharma Delete the data table has no effect, it must change to another data table to work.

ltsharma commented 3 years ago

Hi, there is no such limitations for the number of columns for the table, it should work. Can you make sure the column name you have given while creating & the column names while inserting are same? Because your error shows different column names than you created...

codthing commented 3 years ago

@ltsharma It needs to reinstall the app or modify the table name to work.

ltsharma commented 3 years ago

Will consider as a feature request, thank you for your time 😃