cloudspannerecosystem / yo

yo is a command-line tool to generate Go code for Google Cloud Spanner.
MIT License
312 stars 52 forks source link

Fix NewSpannerLoaderFromDDL to check if table exists #70

Closed 0g3 closed 3 years ago

0g3 commented 3 years ago

What this PR does ?

Fixed not to panic when undefined table is specified in the "CreateIndex" statement.

Example of panic: When FooTable is undefined,

CREATE INDEX FooTableByBarField ON FooTable(BarField);

causes the following panic.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x16ec3bc]

goroutine 1 [running]:
go.mercari.io/yo/loaders.(*SpannerLoaderFromDDL).TableList(0xc00059e090, 0xc0005a20d8, 0x199, 0x101, 0xc000000180, 0xc000448000)
        /Users/bob/go/pkg/mod/go.mercari.io/yo@v0.3.8/loaders/parser.go:94 +0xdc
...

This often happens because of typos.

google-cla[bot] commented 3 years ago

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

0g3 commented 3 years ago

@googlebot I fixed it.

kazegusuri commented 3 years ago

Nice catch! Thank you for your contribution.