andpor / react-native-sqlite-storage

Full featured SQLite3 Native Plugin for React Native (Android and iOS)
MIT License
2.76k stars 520 forks source link

plugin.warn is not a function #402

Open sammysium opened 4 years ago

sammysium commented 4 years ago

I am doing a simple insert query that contains different data types (if it matters) and i get the error "plugin.warn is not a function": where data is a dictionary object passed to the method.

is_active, status,user_id are integers all the rest are strings.


var dt = new Date();

db.transaction(function(tx) {

            tx.executeSql('INSERT INTO client (auto_id,user_id,username,first_name,last_name,email,is_active,date_joined,status,birthdate,marital_status,gender,phone,identification,nationality,lang,syncedon) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
            [
             auto_id,0,data.username,data.firstName,data.lastName,data.email,0,dt,1,data.birthdate,data.maritalStatus,data.gender,data.phone,data.idnumber,data.nation,data.lang,null

            ]

            );
          }, function(error) {
            console.log('Transaction ERROR: ' + error.message);
            reject(false)
          }, function() {
            console.log('Populated database OK');
            resolve(true)
          });

There are few examples on data manipulation. Am I even doing the insert right?

ramakrishnavarma commented 4 years ago

H

I am doing a simple insert query that contains different data types (if it matters) and i get the error "plugin.warn is not a function": where data is a dictionary object passed to the method.

is_active, status,user_id are integers all the rest are strings.


var dt = new Date();

db.transaction(function(tx) {

            tx.executeSql('INSERT INTO client (auto_id,user_id,username,first_name,last_name,email,is_active,date_joined,status,birthdate,marital_status,gender,phone,identification,nationality,lang,syncedon) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
            [
             auto_id,0,data.username,data.firstName,data.lastName,data.email,0,dt,1,data.birthdate,data.maritalStatus,data.gender,data.phone,data.idnumber,data.nation,data.lang,null

            ]

            );
          }, function(error) {
            console.log('Transaction ERROR: ' + error.message);
            reject(false)
          }, function() {
            console.log('Populated database OK');
            resolve(true)
          });

There are few examples on data manipulation. Am I even doing the insert right?

Hi @sammysium remove new Data(). it will work

mnzaki commented 4 years ago

I'm hitting this as well! Triggering an error on this line: https://github.com/andpor/react-native-sqlite-storage/blob/4.1.0/lib/sqlite.core.js#L507 by doing something like:

const listOfThings = ['foo', 'bar']

typeormConn
  .getRepository(SomeRepo)
  .createQueryBuilder('somerepo')
  .leftJoinAndSelect(
    'somerepo.otherrepo',
    'otherrepo',
  )
  // otherrepo.things is of type "simple-json"
  .where('otherrepo.things = :listOfThings', { listOfThings })
  .getMany()

full code: https://github.com/jolocom/smartwallet-app/blob/24b61f12a23de08559ac296dd7985f5e4ab75d6b/src/lib/storage/storage.ts#L173

blainefricks commented 4 years ago

I'm also getting this same error. Doing a simple insert similar to @sammysium. The function call used to work until I updated my project from using react-native-sqlite-storage 3.3.11 to 5.0.0.

nppull commented 4 years ago

same problem.. my project update from react-native-sqlite-storage 3.3.3 to 5.0.0, RN0.62.2

Screen Shot 2020-08-27 at 10 30 38

nppull commented 4 years ago

thanks @mnzaki remove this line fixed for me 👍 💯 👯

plugin.warn('addStatement - parameter of type <'+t+'> converted to string using toString()')

vikil143 commented 3 years ago

Same issue happen at insert query

ReddyyZ commented 3 years ago

I was getting this error with Date objects, I fixed it with date.toString();