Closed lybaiyy123 closed 4 years ago
Kindly fill out the environment setup.
I have tried it with parse-dashboard 2.1.0 and worked just fine. Make sure you have the latest version of client SDK and server.
Kindly fill out the environment setup. client sdk https://unpkg.com/parse@2.12.0/dist/parse.min.js server "dependencies": { "express": "^4.17.1", "graphql": "^14.6.0", "parse": "^2.12.0", "parse-dashboard": "^2.0.5", "parse-server": "^4.1.0", "redis":"^3.0.2" }
when i try other class to decrement / increment ,itis ok。 so,i donot know why the client throw the uncaught error...
The fact that it says TypeError
indicates that the current value of num
is NaN
.
Number
in the Parse Dashboardnum
for object fFmIioVyHd
is directly in the database.Keep in mind that null
is a value, it does not mean that there is no value set. The left field has value null
which cannot be incremented, the right field has no value defined which can be incremented because it is treated as 0
:
The fact that it says
TypeError
indicates that the current value ofnum
isNaN
.
- Check whether the column is really of type
Number
in the Parse Dashboard- Check what the current value of
num
is directly in the database. -.- iam sure the column is 'Number',
You wrote:
when i try other class to decrement / increment ,itis ok。
fFmIioVyHd
?num_test
in Parse Dashboard and without setting any value, you try to increment it, does it work?public read + write
, does it work?You wrote:
when i try other class to decrement / increment ,itis ok。
- Does it only affect this class or only this object
fFmIioVyHd
?- If you create a new column
num_test
in Parse Dashboard and without setting any value, you try to increment it, does it work?
Maybe the schema is corrupted, can you post it here?
If you create a new class with num
column and you try to increment it, does it work?
Maybe the schema is corrupted, can you post it here?
If you create a new class with
num
column and you try to increment it, does it work?
Maybe the schema is corrupted, can you post it here?
If you create a new class with
num
column and you try to increment it, does it work?
1.other class ,column 'num' to increment it,its ok.. 2.new class,column 'num' to increment it,its ok..
This looks like a data inconsistency somewhere.
num_test
and increment it?
- Did you manually manipulate data, schema or anything else in the database at some point?
- Did you try to create a new column
num_test
and increment it?- Would recreating the class solve the issue?
Glad to hear the issue is solved.
But the reason was not found
You can further investigate this issue by running the increment
code in Cloud Code and debugging Parse Server. Look where the TypeError
occurs, what the value of num
is and go from there. Feel free to post your findings here.
You can further investigate this issue by running the
increment
code in Cloud Code and debugging Parse Server. Look where theTypeError
occurs, what the value ofnum
is and go from there. Feel free to post your findings here.
ok,i will have a try, thanks your help
Recurrence steps step 1: Delete the Class 'goods'
step2:
Parse.Cloud.run('goods_update',{player:DB.player.id,num:10000000,name:'one_goods_name'})
the Cloud is:
Parse.Cloud.define('goods_update',req=>{`
var {player,name,num=1}=req.params
let g=new Parse.Query('goods')
g.equalTo('player',player)
g.equalTo('name',name)
return g.first({useMasterKey:true}).then(data=>{
console.log('===goods_update===')
if (!data){
if (num > 0){
console.log(typeof num)
let a = new Parse.Object('goods')
a.set('player', player)
a.set('name', name)
a.set('type', GOODS[name].type)
a.increment('num', num)
a.set('level',GOODS[name].level)
let acl = new Parse.ACL()
acl.setReadAccess(req.user,true)
acl.setWriteAccess(req.user,true)
a.setACL(acl)
return a.save(null, { useMasterKey: true })
}else{
throw new Parse.Error(1001,`${name} less than need`)
}
}else{
if (num < 0 && data.get('num') < Math.abs(num)){
throw new Parse.Error(1001,`${name} less than need`)
}
data.increment('num', num)
return data.save(null,{useMasterKey:true})
}
})
})
step3 : Execute on client
var ccc=new Parse.Object('goods');
ccc.id='GPJ1Dl4psa'
ccc.increment('num',-2)
ccc.save().then((data)=>{console.log(data.get('num'))})
You can further investigate this issue by running the
increment
code in Cloud Code and debugging Parse Server. Look where theTypeError
occurs, what the value ofnum
is and go from there. Feel free to post your findings here. if not exec Parse.Cloud.run('goods_update',{player:DB.player.id,num:10000000,name:'one_goods_name'}) there is no error
@lybaiyy123 Since you are the only one who can reproduce the issue so far, I can only guide you in saying that you can look into the Parse Server code and set a breakpoint at where the type error happens, then inspect the variables and look at what the value of num
is. That should give you a hint to investigate further. You can find instructions on how to set this up and run parse server locally here.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I'm closing this issue due to inactivity and it was not possible to reproduce the issue. Feel free to re-open if you have any questions.
Issue Description
js-sdk https://unpkg.com/parse@2.12.0/dist/parse.min.js decrement and increment throw Uncaught (in promise) TypeError: Cannot increment a non-numeric value.
Steps to reproduce
var g=new Parse.Object('goods') g.id='fFmIioVyHd' g.decrement('num',1) g.save().then(data=>{console.log(data)},e=>(err(e)))
Data exists on the server and the field 'num' is Number but client throw Uncaught (in promise) TypeError: Cannot increment a non-numeric value. also when i use g.decrement('num',10) report the same error There is a chance of reporting an error,
Expected Results
no error
Actual Outcome
g.decrement('num',1) g.save().then(data=>{console.log(data)},e=>(err(e))) Promise {}
VM536:2 l {id: "fFmIioVyHd", _localId: undefined, _objCount: 1608, className: "goods"}
parse.min.js:13 Uncaught (in promise) TypeError: Cannot increment a non-numeric value.
at n.value (parse.min.js:13)
at Object.r.estimateAttributes (parse.min.js:13)
at Object.r.estimateAttributes (parse.min.js:13)
at l.get (parse.min.js:13)
at l.value (parse.min.js:13)
at Object.ee [as matchesQuery] (parse.min.js:13)
at parse.min.js:13
at Array.map ()
at f. (parse.min.js:13)
at f (parse.min.js:13)
save operation send to the server and data is right
Environment Setup
Server
Database
Logs/Trace