teodevgroup / teo

Schema-driven web server framework.
https://teodev.io
Apache License 2.0
1.33k stars 43 forks source link

Schema bug #60

Closed akelyasir closed 2 months ago

akelyasir commented 2 months ago

Hi @victorteokw

I was trying to try examples from the documentation. But at some point I get an error. It gives an error in the fullName section.

model User {
    firstName: String
    lastName: String
    @getter($self.get(.firstName).append(" ").append($self.get(.lastName)))
    @setter($assign(.firstName, $split(" ").get(0)).assign(.lastName, $split(" ").get(1)))
    fullName: String
}
Error: ./schema/index.teo:32:35 - 32:41
|     @getter($self.get(.firstName).append(" ").append($self.get(.lastName)))
|                                   ^^^^^^
callable variant not found for arguments
Error: ./schema/index.teo:32:54 - 32:74
|     @getter($self.get(.firstName).append(" ").append($self.get(.lastName)))
|                                                      ^^^^^^^^^^^^^^^^^^^^
unexpected pipeline output: expect String, found String?
Error: ./schema/index.teo:32:47 - 32:53
|     @getter($self.get(.firstName).append(" ").append($self.get(.lastName)))
|                                               ^^^^^^
callable variant not found for arguments
Error: ./schema/index.teo:33:33 - 33:51
|     @setter($assign(.firstName, $split(" ").get(0)).assign(.lastName, $split(" ").get(1)))
|                                 ^^^^^^^^^^^^^^^^^^
unexpected pipeline output: expect String, found String?
Error: ./schema/index.teo:33:71 - 33:89
|     @setter($assign(.firstName, $split(" ").get(0)).assign(.lastName, $split(" ").get(1)))
|                                                                       ^^^^^^^^^^^^^^^^^^
unexpected pipeline output: expect String, found String?
victorteokw commented 2 months ago

Hi @akelyasir, sorry for this. The documentation is not up-to-date. I will update this example and paste the updated code here.

victorteokw commented 2 months ago

Hi @akelyasir, use this

model User {
    firstName: String
    lastName: String
    @getter($self.get(.firstName).presents.append(" ").append($self.get(.lastName).presents))
    @setter($assign(.firstName, $split(" ").get(0).presents).assign(.lastName, $split(" ").get(1).presents))
    fullName: String
}