[ 
https://issues.apache.org/jira/browse/THRIFT-3122?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14582226#comment-14582226
 ] 

ASF GitHub Bot commented on THRIFT-3122:
----------------------------------------

GitHub user itkach opened a pull request:

    https://github.com/apache/thrift/pull/519

    THRIFT-3122 Convert plain js objects given as thrift struct constructor 
arguments to thrift structs

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/itkach/thrift THRIFT-3122

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/thrift/pull/519.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #519
    
----
commit 29b28079ef4c72c74cb6d3234ae3abd2d38168dd
Author: Igor Tkach <[email protected]>
Date:   2015-04-29T02:50:10Z

    Construct struct instances from arguments

commit 5644aeaa4ba92d93d48014b838d7f8eaa89d52a8
Author: Igor Tkach <[email protected]>
Date:   2015-04-29T03:32:07Z

    When initializing struct from arguments create new struct instances for 
list and sets of structs

commit 831712e586b935ea54f2b3b73e451e5a25a7fd7d
Author: Igor Tkach <[email protected]>
Date:   2015-04-29T21:30:05Z

    Construct struct from map values

commit cd8b5379d014ab218e2e1b48a2b37fad1571c3eb
Author: Igor Tkach <[email protected]>
Date:   2015-04-30T00:41:04Z

    Rename js copy functions to make it clearer what they are when polluting 
global in non-commonJS environment

commit 3929979f8e4fa5cc263c814dd44cc6fd724b09bb
Author: Igor Tkach <[email protected]>
Date:   2015-05-01T17:10:13Z

    Implement copying structs inside deeply nested containers

commit 9d5f1d840b0aaa4aee92cbb4cb9d1ff36cfb92d0
Author: Igor Tkach <[email protected]>
Date:   2015-05-04T14:21:29Z

    Merge github.com:apache/thrift into THRIFT-3122

commit ec35a61f9c44ea65de42fb30f214f58138fe5d4c
Author: Igor Tkach <[email protected]>
Date:   2015-05-04T19:15:04Z

    Do not mutate type list arg

commit 1ac3cba95a3b3c00ad4d7e7b2988ffac1b682f20
Author: Igor Tkach <[email protected]>
Date:   2015-05-04T19:15:38Z

    Rework deep constructor js unit tests

commit 4edfa95c8c487562cff1302a40c888b065f94e62
Author: Igor Tkach <[email protected]>
Date:   2015-05-04T19:26:41Z

    Undo changes in test/ThriftTest.thrift, it's no longer used for js deep 
constructor test

commit c4a7909802e5c46d71da1ec9afab55708f33cb69
Author: Igor Tkach <[email protected]>
Date:   2015-05-06T18:19:00Z

    Don't blow up if arg value for struct member of container type is null

commit 0af437714bbc0b12ae19e21b4ce21b6fdeded772
Author: Igor Tkach <[email protected]>
Date:   2015-05-07T02:13:42Z

    Appease jslint

commit 6314b1172807b389c8d59fc3f1172e3ce3989355
Author: Igor Tkach <[email protected]>
Date:   2015-05-17T00:55:14Z

    Move container copy functions out of generator

commit 688b7d85645884e1731d9fb10dfaee3007ffe7fb
Author: Igor Tkach <[email protected]>
Date:   2015-05-17T21:18:59Z

    Add js deep constructor tests

commit 35b6163199ee2dd8d30689fdb429656aaa09330d
Author: Igor Tkach <[email protected]>
Date:   2015-05-17T21:22:58Z

    Fix list handling error in js/nodejs json protocol
    
    This error prevented proper deserialization of lists containing lists.

commit f9b1ca80e519c133ce744126c8e05f05ff783445
Author: Igor Tkach <[email protected]>
Date:   2015-05-17T21:27:07Z

    Copy fix for handling lists inside maps from js json protocol implementation

commit 231ff444a39fd13d902681d46190ff199bd7c1be
Author: Igor Tkach <[email protected]>
Date:   2015-05-17T21:29:04Z

    Run deep constructor tests with both binary and json 
serializtion/deserialization

commit b89cf398c9482a96906bc35decef8a9446c12412
Author: Igor Tkach <[email protected]>
Date:   2015-05-17T21:33:58Z

    Remove test debug output

commit 4502c457cf523fbbc8816b40925bb006a316b808
Author: Igor Tkach <[email protected]>
Date:   2015-05-29T12:59:26Z

    testAll.sh didn't run code generator before running deep-constructor.test.js

commit 861d262c66f21ad85343ef419d0081ba294e158a
Author: Igor Tkach <[email protected]>
Date:   2015-06-08T17:37:35Z

    Use buffer-equals polyfill for Node 0.10 compatibility

commit 7015b9e760d8c6f92a9cf5ccc12cb9d0d02cacce
Author: itkach <[email protected]>
Date:   2015-06-09T12:48:55Z

    Merge pull request #1 from apache/master
    
    rebase

commit 50e6c6b1639ecece517f00e33831a2a0b5ccb637
Author: Igor Tkach <[email protected]>
Date:   2015-06-09T13:45:40Z

    Merge remote-tracking branch 'origin/master' into THRIFT-3122

----


> Javascript struct constructor should properly initialize struct and container 
> members from plain js arguments
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-3122
>                 URL: https://issues.apache.org/jira/browse/THRIFT-3122
>             Project: Thrift
>          Issue Type: Improvement
>          Components: JavaScript - Compiler
>            Reporter: Igor Tkach
>             Fix For: 0.9.3
>
>
> Currently constructors for struct types in generated javascript accept 
> {{args}} object and initialize struct's members by simply assigning a value 
> from corresponding {{args}} object property (if not undefined). If struct 
> member is
> another struct it must be explicitly created with constructor and passed as 
> an argument value.
> Given following definitions:
> {code}
> struct A {
>        1: string something
> }
> struct B {
>        1: A value
> }
> {code}
> this works:
> {code:javascript}
> var b1 = new B(
>   {
>     value: new A(
>       {
>         something: 'hello'
>       }
>     )
>   }
> );
> {code}
> this doesn't:
> {code:javascript}
> var b2 = new B(
>   {
>     value: {
>       something: 'hello'
>     }
>   }
> );
> {code}
> Attempt to serialize b2 will result in error because {{b2.a}} doesn't have a 
> {{write}} method.
> This becomes especially problematic when deep objects are used with libraries 
> like [Underscore.js|http://underscorejs.org/], [lodash|https://lodash.com/], 
> [React's immutability 
> helpers|https://facebook.github.io/react/docs/update.html] or 
> [Immutable.js|https://github.com/facebook/immutable-js]: most operations will 
> return or produce plain javascript objects without read/write methods even if 
> Thrift objects were given as input. Manually converting object graphs back to 
> Thrift serializable form is not workable.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to