How to fix code problems with GitHub Copilot

docx

School

Australian Institute of Business *

*We aren’t endorsed by this school

Course

MISC

Subject

Computer Science

Date

Nov 24, 2024

Type

docx

Pages

3

Uploaded by assessmentst

Report
How to fix code problems with GitHub Copilot Now, we will see how to fix code problems. First, we have the following T-SQL code: SELECT [ Title ] FROM [ AdventureWorks2019 ].[ Person ].[ Person ] WHERE TITLE = NULL We are trying to find the titles that are null, but this query does not show any result. Secondly, we will select the code, right-click, and select the Copilot>Fix This option. Fix code Thirdly Copilot suggests using IS NULL instead of =. Accept or discharge changes
The fixed code is the following: SELECT [ Title ] FROM [ AdventureWorks2019 ].[ Person ].[ Person ] WHERE TITLE IS NULL ; We cannot use = because NULL is the absence of a value. Then the IS NULL should be used. As you can see, copilot can help to fix some errors. How to generate comments with GitHub Copilot Another nice thing about Copilot is that you can generate comments to explain the code. Let me show you an example in order to understand what I mean. First, we have this code: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SELECT TABLE_NAME FROM INFORMATION_SCHEMA . VIEWS WHERE TABLE_TYPE = 'VIEW' Secondly, we want to generate comments for this code. To do it, select the code. Right-click and select the Copilot>Generate Docs.
Finally, Copilot will generate comments for the line selected. /* This SQL script selects the names of all views in the current database. It uses the INFORMATION_SCHEMA.VIEWS system view to retrieve the names of all views that have been defined in the database. The WHERE clause filters the results to only include views, as opposed to other types of objects that may be defined in the database. */ Conclusion In this article, we learned how to use the Copilot chat and send orders to generate code. Also, we used the explain this feature to explain code. In addition, we used the feature to fix code. We sent some code and Copilot found the problem. Finally, we learned how to generate Copilot T-SQL comments on selected lines of code. In general terms, I prefer ChatGPT . I think it makes fewer mistakes than the copilot. For me, GitHub Copilot looks like a ChatGPT version 2.0. Anyway, it is a nice technology. The AI is amazing, but it is not the best tool in the market right now. Images Some images were generated in Bing image creator.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help