Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2164] ACS - Critical Bug with custom_fileds.

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionFixed
Resolution Date2014-02-14T07:22:30.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterJong Eun Lee
AssigneeRitu Agrawal
Created2013-12-28T01:11:15.000+0000
Updated2016-03-08T07:41:09.000+0000

Description

When I save google api result string(or object) to custom_files, there is a critical bug. Case 1 Step: 1. Create post with custom_fields which has google api result string. 2. Post.Query with no where condition, you can't find a just created post in the result. 3. Post.Query with "where:{id:created_id}" condition, you can find a just create post. If you set google api result to 'title', All step work property. (Case 2) If you use other string instead of google api result, All step work property. Yes! It's wired! It's true! run below code. You could understand what I'm saying.
var Cloud = require('ti.cloud');

function createPostAndQuery() {

	Cloud.Posts.create({
		/**
		 * test case 1 : custom_fileds string
		 * actual result : Cloud.Show work!,
		 * 				   Cloud.Query(with where:{id:xxx}) work!
		 * 				   Cloud.Query(with no where) DOESN'T FIND POST JUST CREATED!!!! 
		 */
		content : 'custom_fileds string',
		custom_fields : {
			myField : JSON.stringify(googleReverseGeo)
		}
		
		
		/**
		 * test case 2 : custom_fileds string
		 * actual result : Cloud.Show work!,
		 * 				   Cloud.Query(with no where) work!!!!! 
		 */
		// content : 'no custom_fileds',
		// title :  JSON.stringify(googleReverseGeo)
		
		
	}, function(e) {
		if (e.success) {
			var created_post = e.posts[0];
			alert('CREATE Success:\n' + 'id: ' + created_post.id + '\n' 
				+ 'title: ' + created_post.title + '\n' 
				+ 'content: ' + created_post.content + '\n' 
				+ 'updated_at: ' + created_post.updated_at + '\n',
				+ 'custom_fields' + JSON.stringify(created_post.custom_fields));
			
			Cloud.Posts.show({
				post_id : created_post.id
			}, function(e) {
				if (e.success) {
					var post = e.posts[0];
					alert('SHOW Success:\n' + 'id: ' + post.id + '\n' + 'title: ' + post.title + '\n' + 'content: ' + post.content + '\n' + 'updated_at: ' + post.updated_at + '\n' + 'custom_fields' + JSON.stringify(created_post.custom_fields));
				} else {
					alert('SHOW Error:\n' + ((e.error && e.message) || JSON.stringify(e)));
				}
			});
			
			
			Cloud.Posts.query({
			    page: 1,
			    per_page: 20,
			    // where : {
			    	// id : created_post.id
			    // }
			}, function (e) {
			    if (e.success) {
			    	var isFound = false,
			    		queryPost;
			        for (var i = 0; i < e.posts.length; i++) {
			            var post = e.posts[i];
			            if(post.id == created_post.id){
			            	isFound = true;
			            	queryPost = post;
			            }
			        }
			        if(isFound){
			        	alert(
			        		'QUERY Success:\n' +
			        		'id: ' + queryPost.id + '\n' +
			                'id: ' + queryPost.id + '\n' +
			                'title: ' + queryPost.title + '\n' +
			                'content: ' + queryPost.content + '\n' +
			                'updated_at: ' + queryPost.updated_at + '\n' + 
			                'custom_fields' + JSON.stringify(queryPost.custom_fields));
			        } else {
			        	alert ('QUERY : Opps!'+'\n'+
			        		'post length : ' + e.posts.length +'\n'+ 
			        		'There is no post_id :' + created_post.id);
			        }
			          
			    } else {
			        alert('QUERY Error:\n' +
			            ((e.error && e.message) || JSON.stringify(e)));
			    }
			});
		} else {
			alert('CREATE Error:\n' + ((e.error && e.message) || JSON.stringify(e)));
		}
	});
}


Cloud.Users.login({
    login: 'test@mycompany.com',
    password: 'test_password'
}, function (e) {
    if (e.success) {
        createPostAndQuery();
    } else {
        alert('LOGIN Error:\n' +
            ((e.error && e.message) || JSON.stringify(e)));
    }
});

// result of https://developers.google.com/maps/documentation/geocoding/#ReverseGeocoding
var googleReverseGeo = {"results":[{"address_components":[{"long_name":"365-11","short_name":"365-11","types":["political"]},{"long_name":"Sindorim-dong","short_name":"Sindorim-dong","types":["sublocality","political"]},{"long_name":"Guro-gu","short_name":"Guro-gu","types":["sublocality","political"]},{"long_name":"Seoul","short_name":"Seoul","types":["locality","political"]},{"long_name":"South Korea","short_name":"KR","types":["country","political"]},{"long_name":"152-070","short_name":"152-070","types":["postal_code"]}],"formatted_address":"365-11 Sindorim-dong, Guro-gu, Seoul, South Korea","geometry":{"location":{"lat":37.5096051,"lng":126.8872816},"location_type":"APPROXIMATE","viewport":{"northeast":{"lat":37.5184557,"lng":126.903289},"southwest":{"lat":37.5007535,"lng":126.8712742}}},"types":["political"]},{"address_components":[{"long_name":"Sindorim-dong","short_name":"Sindorim-dong","types":["sublocality","political"]},{"long_name":"Guro-gu","short_name":"Guro-gu","types":["sublocality","political"]},{"long_name":"Seoul","short_name":"Seoul","types":["locality","political"]},{"long_name":"South Korea","short_name":"KR","types":["country","political"]},{"long_name":"152-070","short_name":"152-070","types":["postal_code"]}],"formatted_address":"Sindorim-dong, Guro-gu, Seoul, South Korea","geometry":{"bounds":{"northeast":{"lat":37.5182288,"lng":126.8922686},"southwest":{"lat":37.5031568,"lng":126.873054}},"location":{"lat":37.509469,"lng":126.882105},"location_type":"APPROXIMATE","viewport":{"northeast":{"lat":37.5182288,"lng":126.8922686},"southwest":{"lat":37.5031568,"lng":126.873054}}},"types":["sublocality","political"]},{"address_components":[{"long_name":"Sindorim-dong","short_name":"Sindorim-dong","types":["sublocality","political"]},{"long_name":"Guro-gu","short_name":"Guro-gu","types":["sublocality","political"]},{"long_name":"Seoul","short_name":"Seoul","types":["locality","political"]},{"long_name":"South Korea","short_name":"KR","types":["country","political"]},{"long_name":"152-070","short_name":"152-070","types":["postal_code"]}],"formatted_address":"Sindorim-dong, Guro-gu, Seoul, South Korea","geometry":{"bounds":{"northeast":{"lat":37.5182288,"lng":126.8922686},"southwest":{"lat":37.5031568,"lng":126.873054}},"location":{"lat":37.5077345,"lng":126.8805914},"location_type":"APPROXIMATE","viewport":{"northeast":{"lat":37.5182288,"lng":126.8922686},"southwest":{"lat":37.5031568,"lng":126.873054}}},"types":["sublocality","political"]},{"address_components":[{"long_name":"152-070","short_name":"152-070","types":["postal_code"]},{"long_name":"Sindorim-dong","short_name":"Sindorim-dong","types":["sublocality","political"]},{"long_name":"Guro-gu","short_name":"Guro-gu","types":["sublocality","political"]},{"long_name":"Seoul","short_name":"Seoul","types":["locality","political"]},{"long_name":"South Korea","short_name":"KR","types":["country","political"]}],"formatted_address":"Sindorim-dong, Guro-gu, Seoul, South Korea","geometry":{"bounds":{"northeast":{"lat":37.5182288,"lng":126.8922686},"southwest":{"lat":37.5031568,"lng":126.873054}},"location":{"lat":37.5114119,"lng":126.8815276},"location_type":"APPROXIMATE","viewport":{"northeast":{"lat":37.5182288,"lng":126.8922686},"southwest":{"lat":37.5031568,"lng":126.873054}}},"types":["postal_code"]},{"address_components":[{"long_name":"Guro-gu","short_name":"Guro-gu","types":["sublocality","political"]},{"long_name":"Seoul","short_name":"Seoul","types":["locality","political"]},{"long_name":"South Korea","short_name":"KR","types":["country","political"]}],"formatted_address":"Guro-gu, Seoul, South Korea","geometry":{"bounds":{"northeast":{"lat":37.5182288,"lng":126.9030494},"southwest":{"lat":37.4733012,"lng":126.8126901}},"location":{"lat":37.4954031,"lng":126.887369},"location_type":"APPROXIMATE","viewport":{"northeast":{"lat":37.5182288,"lng":126.9030494},"southwest":{"lat":37.4733012,"lng":126.8126901}}},"types":["sublocality","political"]},{"address_components":[{"long_name":"Seoul","short_name":"Seoul","types":["locality","political"]},{"long_name":"South Korea","short_name":"KR","types":["country","political"]}],"formatted_address":"Seoul, South Korea","geometry":{"bounds":{"northeast":{"lat":37.7017495,"lng":127.18359},"southwest":{"lat":37.4259627,"lng":126.7645827}},"location":{"lat":37.566535,"lng":126.9779692},"location_type":"APPROXIMATE","viewport":{"northeast":{"lat":37.6956,"lng":127.1823},"southwest":{"lat":37.4346,"lng":126.7968}}},"types":["locality","political"]},{"address_components":[{"long_name":"South Korea","short_name":"KR","types":["country","political"]}],"formatted_address":"South Korea","geometry":{"bounds":{"northeast":{"lat":38.6169312,"lng":130.9232178},"southwest":{"lat":33.1061096,"lng":124.608139}},"location":{"lat":35.907757,"lng":127.766922},"location_type":"APPROXIMATE","viewport":{"northeast":{"lat":38.6169312,"lng":129.584671},"southwest":{"lat":33.1061096,"lng":124.608139}}},"types":["country","political"]}],"status":"OK"};

This is not only post bug. When I tested with Photo object, I got a same result.

Comments

  1. Ritu Agrawal 2014-01-05

    Thank you for reporting this issue. We have been able to reproduce this issue based on the steps provided. We have created ticket CLOUDSRV-3116 to track this issue on engineering side. We will continue to update this ticket as we receive more information from engineering.
  2. Ritu Agrawal 2014-02-14

    This issue has been fixed and deployed on the production environment. Please give it a try and let us know if this issue is resolved for you.

JSON Source